summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp21
-rw-r--r--libkcal/kincidenceformatter.cpp22
-rw-r--r--libkcal/recurrence.cpp2
-rw-r--r--microkde/kdeui/ktoolbar.cpp2
-rw-r--r--microkde/kdeui/ktoolbar.h2
5 files changed, 30 insertions, 19 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index de11c13..39921a0 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -258,110 +258,113 @@ void KOEventViewer::appendEvent(Event *event, int mode )
addTag("h2",i18n( "Local: " ) +event->summary());
} else {
addTag("h2",i18n( "Remote: " ) +event->summary());
}
addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
if ( mColorMode )
mText += "</font>";
}
mMailSubject += i18n( "Meeting " )+ event->summary();
if (event->cancelled ()) {
mText +="<font color=\"#B00000\">";
addTag("i",i18n("This event has been cancelled!"));
mText.append("<br>");
mText += "</font>";
mMailSubject += i18n("(cancelled)");
}
if (!event->location().isEmpty()) {
addTag("b",i18n("Location: "));
mText.append(event->location()+"<br>");
mMailSubject += i18n(" at ") + event->location();
}
if (event->doesFloat()) {
if (event->isMultiDay()) {
mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
.arg(event->dtStartDateStr(shortDate))
.arg(event->dtEndDateStr(shortDate)));
} else {
mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
}
} else {
if (event->isMultiDay()) {
mText.append(i18n("<p><b>From:</b> %1</p> ")
.arg(event->dtStartStr( shortDate)));
mText.append(i18n("<p><b>To:</b> %1</p>")
.arg(event->dtEndStr(shortDate)));
} else {
mText.append(i18n("<p><b>On:</b> %1</p> ")
.arg(event->dtStartDateStr( shortDate )));
mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
.arg(event->dtStartTimeStr())
.arg(event->dtEndTimeStr()));
}
}
if (event->recurrence()->doesRecur()) {
QString recurText = event->recurrence()->recurrenceText();
addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
- bool last;
+ bool ok;
QDate start = QDate::currentDate();
- QDate next;
- next = event->recurrence()->getPreviousDate( start , &last );
- if ( !last ) {
- next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
+ QDateTime next;
+ next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
+ if ( ok ) {
addTag("p",i18n("<b>Next recurrence is on:</b>") );
- addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
- QDateTime nextdt = QDateTime( next, event->dtStart().time());
- mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
+ addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
+ mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
} else {
+ bool last;
+ QDate nextd;
+ nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
+ if ( last ) {
addTag("p",i18n("<b>Last recurrence was on:</b>") );
- addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
+ addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
+ }
}
} else {
mMailSubject += i18n(" - " )+event->dtStartStr( true );
}
if (event->isAlarmEnabled()) {
Alarm *alarm =event->alarms().first() ;
QDateTime t = alarm->time();
int min = t.secsTo( event->dtStart() )/60;
QString s =i18n("( %1 min before )").arg( min );
addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
//addTag("p",s);
}
addTag("b",i18n("Access: "));
mText.append(event->secrecyStr()+"<br>");
if (!event->description().isEmpty()) {
addTag("p",i18n("<b>Details: </b>"));
addTag("p",event->description());
}
formatCategories(event);
formatReadOnly(event);
formatAttendees(event);
setText(mText);
//QWhatsThis::add(this,mText);
}
void KOEventViewer::appendTodo(Todo *event, int mode )
{
mMailSubject = "";
mCurrentIncidence = event;
topLevelWidget()->setCaption(i18n("Todo Viewer"));
bool shortDate = KOPrefs::instance()->mShortDateInViewer;
if (mode == 0 )
addTag("h2",event->summary());
else {
if ( mColorMode == 1 ) {
mText +="<font color=\"#00A000\">";
}
if ( mColorMode == 2 ) {
mText +="<font color=\"#B00000\">";
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 6d07d4c..0d9c3f4 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -59,107 +59,113 @@ void KIncidenceFormatter::setEvent(Event *event)
}
// mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
if ( mode == 1 ) {
addTag("h2",i18n( "Local: " ) +event->summary());
} else {
addTag("h2",i18n( "Remote: " ) +event->summary());
}
addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
if ( mColorMode )
mText += "</font>";
}
if (event->cancelled ()) {
mText +="<font color=\"#B00000\">";
addTag("i",i18n("This event has been cancelled!"));
mText.append("<br>");
mText += "</font>";
}
if (!event->location().isEmpty()) {
addTag("b",i18n("Location: "));
mText.append(event->location()+"<br>");
}
if (event->doesFloat()) {
if (event->isMultiDay()) {
mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
.arg(event->dtStartDateStr(shortDate))
.arg(event->dtEndDateStr(shortDate)));
} else {
mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
}
} else {
if (event->isMultiDay()) {
mText.append(i18n("<p><b>From:</b> %1</p> ")
.arg(event->dtStartStr( shortDate)));
mText.append(i18n("<p><b>To:</b> %1</p>")
.arg(event->dtEndStr(shortDate)));
} else {
mText.append(i18n("<p><b>On:</b> %1</p> ")
.arg(event->dtStartDateStr( shortDate )));
mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
.arg(event->dtStartTimeStr())
.arg(event->dtEndTimeStr()));
}
}
if (event->recurrence()->doesRecur()) {
QString recurText = event->recurrence()->recurrenceText();
addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
- bool last;
+
+ bool ok;
QDate start = QDate::currentDate();
- QDate next;
- next = event->recurrence()->getPreviousDate( start , &last );
- if ( !last ) {
- next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
- addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) );
- //addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
+ QDateTime next;
+ next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
+ if ( ok ) {
+ addTag("p",i18n("<b>Next recurrence is on:</b>") );
+ addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
+
} else {
+ bool last;
+ QDate nextd;
+ nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
+ if ( last ) {
addTag("p",i18n("<b>Last recurrence was on:</b>") );
- addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
+ addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
+ }
}
}
if (event->isAlarmEnabled()) {
Alarm *alarm =event->alarms().first() ;
QDateTime t = alarm->time();
int min = t.secsTo( event->dtStart() )/60;
QString s =i18n("(%1 min before)").arg( min );
addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
//addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
//addTag("p",s);
}
addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
// mText.append(event->secrecyStr()+"<br>");
formatCategories(event);
if (!event->description().isEmpty()) {
addTag("p",i18n("<b>Details: </b>"));
addTag("p",event->description());
}
formatReadOnly(event);
formatAttendees(event);
}
void KIncidenceFormatter::setTodo(Todo *event )
{
int mode = 0;
mCurrentIncidence = event;
bool shortDate = true;
if (mode == 0 )
addTag("h3",event->summary());
else {
if ( mColorMode == 1 ) {
mText +="<font color=\"#00A000\">";
}
if ( mColorMode == 2 ) {
mText +="<font color=\"#B00000\">";
}
if ( mode == 1 ) {
addTag("h2",i18n( "Local: " ) +event->summary());
} else {
addTag("h2",i18n( "Remote: " ) +event->summary());
}
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp
index e84f672..5181eaf 100644
--- a/libkcal/recurrence.cpp
+++ b/libkcal/recurrence.cpp
@@ -834,96 +834,97 @@ QDateTime Recurrence::getNextDateTime(const QDateTime &preDateTime, bool *last)
case rYearlyMonth:
case rYearlyDay:
case rYearlyPos: {
QDate preDate = preDateTime.date();
if (!mFloats && mRecurStart.time() > preDateTime.time())
preDate = preDate.addDays(-1);
return QDateTime(getNextDateNoTime(preDate, last), mRecurStart.time());
}
default:
return QDateTime();
}
// It's a sub-daily recurrence
if (preDateTime < mRecurStart)
return mRecurStart;
int count = mRecurStart.secsTo(preDateTime) / freq + 2;
if (rDuration > 0) {
if (count > rDuration)
return QDateTime();
if (last && count == rDuration)
*last = true;
}
QDateTime endtime = mRecurStart.addSecs((count - 1)*freq);
if (rDuration == 0) {
if (endtime > rEndDateTime)
return QDateTime();
if (last && endtime == rEndDateTime)
*last = true;
}
return endtime;
}
QDate Recurrence::getNextDate(const QDate &preDate, bool *last) const
{
if (last)
*last = false;
switch (recurs)
{
case rMinutely:
case rHourly:
return getNextDateTime(QDateTime(preDate, QTime(23,59,59)), last).date();
case rDaily:
case rWeekly:
case rMonthlyPos:
case rMonthlyDay:
case rYearlyMonth:
case rYearlyDay:
case rYearlyPos:
+ qDebug("Recurrence::getNextDate: MAY BE BROKEN ");
return getNextDateNoTime(preDate, last);
default:
return QDate();
}
}
QDateTime Recurrence::getPreviousDateTime(const QDateTime &afterDateTime, bool *last) const
{
if (last)
*last = false;
int freq;
switch (recurs)
{
case rMinutely:
freq = rFreq * 60;
break;
case rHourly:
freq = rFreq * 3600;
break;
case rDaily:
case rWeekly:
case rMonthlyPos:
case rMonthlyDay:
case rYearlyMonth:
case rYearlyDay:
case rYearlyPos: {
QDate afterDate = afterDateTime.date();
if (!mFloats && mRecurStart.time() < afterDateTime.time())
afterDate = afterDate.addDays(1);
return QDateTime(getPreviousDateNoTime(afterDate, last), mRecurStart.time());
}
default:
return QDateTime();
}
// It's a sub-daily recurrence
if (afterDateTime <= mRecurStart)
return QDateTime();
int count = (mRecurStart.secsTo(afterDateTime) - 1) / freq + 1;
if (rDuration > 0) {
if (count > rDuration)
count = rDuration;
if (last && count == rDuration)
*last = true;
}
QDateTime endtime = mRecurStart.addSecs((count - 1)*freq);
if (rDuration == 0) {
@@ -1121,96 +1122,97 @@ bool Recurrence::recursYearlyByPos(const QDate &qd) const
rDuration == -1)) {
// The date queried falls within the range of the event.
for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
if (month == *qlin.current()) {
// The month recurs
QValueList<int> days;
getMonthlyPosDays(days, qd.daysInMonth(), QDate(year, month, 1).dayOfWeek());
for (QValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) {
if (*it == day)
return true;
}
}
}
}
}
return false;
}
bool Recurrence::recursYearlyByDay(const QDate &qd) const
{
QDate dStart = mRecurStart.date();
// calculate how many years ahead this date is from the original
// event's date
int yearsAhead = (qd.year() - dStart.year());
if (yearsAhead % rFreq == 0) {
// The date is in a year which recurs
if (qd >= dStart
&& ((rDuration > 0 && qd <= endDate()) ||
(rDuration == 0 && qd <= rEndDateTime.date()) ||
rDuration == -1)) {
// The date queried falls within the range of the event.
int i = qd.dayOfYear();
for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
if (i == *qlin.current())
return true;
}
}
}
return false;
}
/* Get the date of the next recurrence, after the specified date.
* If 'last' is non-null, '*last' is set to true if the next recurrence is the
* last recurrence, else false.
* Reply = date of next recurrence, or invalid date if none.
*/
QDate Recurrence::getNextDateNoTime(const QDate &preDate, bool *last) const
{
+
if (last)
*last = false;
QDate dStart = mRecurStart.date();
if (preDate < dStart)
return dStart;
QDate earliestDate = preDate.addDays(1);
QDate nextDate;
switch (recurs) {
case rDaily:
nextDate = dStart.addDays((dStart.daysTo(preDate)/rFreq + 1) * rFreq);
break;
case rWeekly: {
QDate start = dStart.addDays(1 - dStart.dayOfWeek()); // start of week for dStart
int earliestDayOfWeek = earliestDate.dayOfWeek();
int weeksAhead = start.daysTo(earliestDate) / 7;
int notThisWeek = weeksAhead % rFreq; // zero if this week is a recurring week
weeksAhead -= notThisWeek; // latest week which recurred
int weekday = 0;
// First check for any remaining day this week, if this week is a recurring week
if (!notThisWeek)
weekday = getFirstDayInWeek(earliestDayOfWeek);
// Check for a day in the next scheduled week
if (!weekday && earliestDayOfWeek > 1)
weekday = getFirstDayInWeek(rWeekStart) + rFreq*7;
if (weekday)
nextDate = start.addDays(weeksAhead*7 + weekday - 1);
break;
}
case rMonthlyDay:
case rMonthlyPos: {
int startYear = dStart.year();
int startMonth = dStart.month(); // 1..12
int earliestYear = earliestDate.year();
int monthsAhead = (earliestYear - startYear)*12 + earliestDate.month() - startMonth;
int notThisMonth = monthsAhead % rFreq; // zero if this month is a recurring month
monthsAhead -= notThisMonth; // latest month which recurred
// Check for the first later day in the current month
if (!notThisMonth)
nextDate = getFirstDateInMonth(earliestDate);
if (!nextDate.isValid() && earliestDate.day() > 1) {
// Check for a day in the next scheduled month
int months = startMonth - 1 + monthsAhead + rFreq;
nextDate = getFirstDateInMonth(QDate(startYear + months/12, months%12 + 1, 1));
}
break;
}
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 09ad0c8..35d4916 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -833,97 +833,97 @@ void KToolBar::hideItem (int id)
w->hide();
}
void KToolBar::showItem (int id)
{
QWidget *w = getWidget(id);
if ( w )
w->show();
}
int KToolBar::itemIndex (int id)
{
QWidget *w = getWidget(id);
return w ? widgets.findRef(w) : -1;
}
void KToolBar::setFullSize(bool flag )
{
setHorizontalStretchable( flag );
setVerticalStretchable( flag );
}
bool KToolBar::fullSize() const
{
return isHorizontalStretchable() || isVerticalStretchable();
}
void KToolBar::enableMoving(bool flag )
{
//US setMovingEnabled(flag);
this->mainWindow()->setToolBarsMovable(flag);
}
void KToolBar::setBarPos (BarPosition bpos)
{
if ( !mainWindow() )
return;
//US mainWindow()->moveDockWindow( this, (Dock)bpos );
mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos );
}
-KToolBar::BarPosition KToolBar::barPos() const
+const KToolBar::BarPosition KToolBar::barPos()
{
if ( !(QMainWindow*)mainWindow() )
return KToolBar::Top;
//US Dock dock;
QMainWindow::ToolBarDock dock;
int dm1, dm2;
bool dm3;
((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 );
//US if ( dock == DockUnmanaged ) {
if ( dock == QMainWindow::Unmanaged ) {
return (KToolBar::BarPosition)Top;
}
return (BarPosition)dock;
}
bool KToolBar::enable(BarStatus stat)
{
bool mystat = isVisible();
if ( (stat == Toggle && mystat) || stat == Hide )
hide();
else
show();
return isVisible() == mystat;
}
void KToolBar::setMaxHeight ( int h )
{
setMaximumHeight( h );
}
int KToolBar::maxHeight()
{
return maximumHeight();
}
void KToolBar::setMaxWidth (int dw)
{
setMaximumWidth( dw );
}
int KToolBar::maxWidth()
{
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h
index 49ff856..7a5c114 100644
--- a/microkde/kdeui/ktoolbar.h
+++ b/microkde/kdeui/ktoolbar.h
@@ -701,97 +701,97 @@ public:
/**
* Show item.
*/
void showItem (int id);
/**
* Returns the index of the given item.
*
* KDE4: make this const!
*/
int itemIndex (int id);
/**
* Set toolbar to full parent size (default).
*
* In full size mode the bar
* extends over the parent's full width or height. If the mode is disabled
* the toolbar tries to take as much space as it needs without wrapping, but
* it does not exceed the parent box. You can force a certain width or
* height with @ref setMaxWidth() or @ref setMaxHeight().
*
* If you want to use right-aligned items or auto-sized items you must use
* full size mode.
*/
void setFullSize(bool flag = true);
/**
* @return @p true if the full-size mode is enabled. Otherwise
* it returns @false.
*/
bool fullSize() const;
/**
* @deprecated use setMovingEnabled(bool) instead.
* Enable or disable moving of toolbar.
*/
void enableMoving(bool flag = true);
/**
* Set position of toolbar.
* @see BarPosition()
*/
void setBarPos (BarPosition bpos);
/**
* Returns position of toolbar.
*/
- BarPosition barPos() const;
+ const BarPosition barPos();
/**
* @deprecated
* Show, hide, or toggle toolbar.
*
* This method is provided for compatibility only,
* please use show() and/or hide() instead.
* @see BarStatus
*/
bool enable(BarStatus stat);
/**
* @deprecated
* Use setMaximumHeight() instead.
*/
void setMaxHeight (int h); // Set max height for vertical toolbars
/**
* @deprecated
* Use maximumHeight() instead.
* Returns the value that was set with @ref setMaxHeight().
*/
int maxHeight();
/**
* @deprecated
* Use setMaximumWidth() instead.
* Set maximal width of horizontal (top or bottom) toolbar.
*/
void setMaxWidth (int dw);
/**
* @deprecated
* Use maximumWidth() instead.
* Returns the value that was set with @ref setMaxWidth().
*/
int maxWidth();
/**
* Set title for toolbar when it floats.
*
* Titles are however not (yet)
* visible. You can't change toolbar's title while it's floating.
*/
void setTitle (const QString& _title);
/**
* @deprecated