summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
-rw-r--r--korganizer/datenavigator.cpp6
-rw-r--r--korganizer/datenavigator.h1
-rw-r--r--korganizer/interfaces/korganizer/baseview.h1
-rw-r--r--korganizer/komonthview.h1
5 files changed, 13 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3908dbb..47cd488 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1898,193 +1898,196 @@ void CalendarView::writeSettings()
wid = getEventViewerDialog();
x = wid->geometry().x();
y = wid->geometry().y();
w = wid->width();
h = wid->height();
list.clear();
list << QString::number( x );
list << QString::number( y );
list << QString::number( w );
list << QString::number( h );
config->writeEntry("ViewerLayout",list );
wid = mDialogManager->getSearchDialog();
if ( wid ) {
x = wid->geometry().x();
y = wid->geometry().y();
w = wid->width();
h = wid->height();
list.clear();
list << QString::number( x );
list << QString::number( y );
list << QString::number( w );
list << QString::number( h );
config->writeEntry("SearchLayout",list );
}
#endif
config->sync();
}
void CalendarView::readFilterSettings(KConfig *config)
{
// kdDebug() << "CalendarView::readFilterSettings()" << endl;
mFilters.clear();
config->setGroup("General");
QStringList filterList = config->readListEntry("CalendarFilters");
QStringList::ConstIterator it = filterList.begin();
QStringList::ConstIterator end = filterList.end();
while(it != end) {
// kdDebug() << " filter: " << (*it) << endl;
CalFilter *filter;
filter = new CalFilter(*it);
config->setGroup("Filter_" + (*it));
//qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
filter->setCriteria(config->readNumEntry("Criteria",0));
filter->setCategoryList(config->readListEntry("CategoryList"));
mFilters.append(filter);
++it;
}
if (mFilters.count() == 0) {
CalFilter *filter = new CalFilter(i18n("Default"));
mFilters.append(filter);
}
mFilterView->updateFilters();
config->setGroup("FilterView");
mFilterView->blockSignals(true);
mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
mFilterView->blockSignals(false);
// We do it manually to avoid it being done twice by the above calls
updateFilter();
}
void CalendarView::writeFilterSettings(KConfig *config)
{
// kdDebug() << "CalendarView::writeFilterSettings()" << endl;
QStringList filterList;
CalFilter *filter = mFilters.first();
while(filter) {
// kdDebug() << " fn: " << filter->name() << endl;
filterList << filter->name();
config->setGroup("Filter_" + filter->name());
config->writeEntry("Criteria",filter->criteria());
config->writeEntry("CategoryList",filter->categoryList());
filter = mFilters.next();
}
config->setGroup("General");
config->writeEntry("CalendarFilters",filterList);
config->setGroup("FilterView");
config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
}
void CalendarView::goToday()
{
- mNavigator->selectToday();
+ if ( mViewManager->currentView()->isMonthView() )
+ mNavigator->selectTodayMonth();
+ else
+ mNavigator->selectToday();
}
void CalendarView::goNext()
{
mNavigator->selectNext();
}
void CalendarView::goPrevious()
{
mNavigator->selectPrevious();
}
void CalendarView::goNextMonth()
{
mNavigator->selectNextMonth();
}
void CalendarView::goPreviousMonth()
{
mNavigator->selectPreviousMonth();
}
void CalendarView::writeLocale()
{
//KPimGlobalPrefs::instance()->setGlobalConfig();
#if 0
KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
QString dummy = KOPrefs::instance()->mUserDateFormatLong;
KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
dummy = KOPrefs::instance()->mUserDateFormatShort;
KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
KOPrefs::instance()->mDaylightsavingStart,
KOPrefs::instance()->mDaylightsavingEnd );
KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
#endif
}
void CalendarView::updateConfig()
{
writeLocale();
if ( KOPrefs::instance()->mUseAppColors )
QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
emit configChanged();
mTodoList->updateConfig();
// mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
// To make the "fill window" configurations work
//mViewManager->raiseCurrentView();
}
void CalendarView::eventChanged(Event *event)
{
changeEventDisplay(event,KOGlobals::EVENTEDITED);
//updateUnmanagedViews();
}
void CalendarView::eventAdded(Event *event)
{
changeEventDisplay(event,KOGlobals::EVENTADDED);
}
void CalendarView::eventToBeDeleted(Event *)
{
kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
}
void CalendarView::eventDeleted()
{
changeEventDisplay(0,KOGlobals::EVENTDELETED);
}
void CalendarView::changeTodoDisplay(Todo *which, int action)
{
changeIncidenceDisplay((Incidence *)which, action);
mDateNavigator->updateView(); //LR
//mDialogManager->updateSearchDialog();
if (which) {
mViewManager->updateWNview();
//mTodoList->updateView();
}
}
void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
{
updateUnmanagedViews();
//qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
if ( action == KOGlobals::EVENTDELETED ) { //delete
mCalendar->checkAlarmForIncidence( 0, true );
if ( mEventViewerDialog )
mEventViewerDialog->hide();
}
else
mCalendar->checkAlarmForIncidence( which , false );
diff --git a/korganizer/datenavigator.cpp b/korganizer/datenavigator.cpp
index e26e20b..3156b2b 100644
--- a/korganizer/datenavigator.cpp
+++ b/korganizer/datenavigator.cpp
@@ -106,182 +106,188 @@ void DateNavigator::selectDate( const QDate &date )
{
QDate d = date;
if ( !d.isValid() ) {
d = QDate::currentDate();
}
mSelectedDates.clear();
mSelectedDates.append( d );
emitSelected();
}
void DateNavigator::selectDates( int count )
{
QDate d = mSelectedDates.first();
selectDates( d, count );
}
void DateNavigator::selectDates( const QDate &d, int count )
{
DateList dates;
int i;
for( i = 0; i < count; ++i ) {
dates.append( d.addDays( i ) );
}
mSelectedDates = dates;
emitSelected();
}
void DateNavigator::selectWeekByDay( int weekDay, const QDate &d )
{
// qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1());
int dateCount = mSelectedDates.count();
bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() );
if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d );
else if ( weekStart && dateCount == 7 ) selectWeek( d );
else selectDates( d, dateCount );
}
void DateNavigator::selectWeek()
{
QDate d = mSelectedDates.first();
selectWeek( d );
}
void DateNavigator::selectWeek( int num )
{
int year = mSelectedDates.first().year();
if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 )
++year;
if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 )
--year;
QDate d = QDate ( year, 1,1);
while ( d.dayOfWeek() != 4 )
d = d.addDays( 1 );
selectWeek( d.addDays ( (num-1) *7 ) );
}
void DateNavigator::selectWeek( const QDate &d )
{
int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
int weekStart = KGlobal::locale()->weekStartDay();
QDate firstDate = d.addDays( weekStart - dayOfWeek );
if ( weekStart != 1 && dayOfWeek < weekStart ) {
firstDate = firstDate.addDays(-7 );
}
selectDates( firstDate, 7 );
}
void DateNavigator::selectWorkWeek()
{
QDate d = mSelectedDates.first();
selectWorkWeek( d );
}
void DateNavigator::selectWorkWeek( const QDate &d )
{
int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
QDate firstDate = d.addDays( 1 - dayOfWeek );
int weekStart = KGlobal::locale()->weekStartDay();
if ( weekStart != 1 && dayOfWeek >= weekStart ) {
firstDate = firstDate.addDays( 7 );
}
selectDates( firstDate, 5 );
}
+void DateNavigator::selectTodayMonth()
+{
+ QDate date = QDate::currentDate().addDays( 1-QDate::currentDate().day() );
+ selectDates( date , date.daysInMonth ());
+
+}
void DateNavigator::selectToday()
{
QDate d = QDate::currentDate();
int dateCount = mSelectedDates.count();
if ( dateCount == 5 ) selectWorkWeek( d );
else if ( dateCount == 7 ) selectWeek( d );
else selectDates( d, dateCount );
}
void DateNavigator::selectPreviousYear()
{
QDate firstSelected = mSelectedDates.first();
int weekDay = firstSelected.dayOfWeek();
firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 );
selectWeekByDay( weekDay, firstSelected );
}
void DateNavigator::selectPreviousMonth()
{
QDate firstSelected = mSelectedDates.first();
int weekDay = firstSelected.dayOfWeek();
firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 );
if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
selectMonthByDate( firstSelected );
else
selectWeekByDay( weekDay, firstSelected );
}
void DateNavigator::selectNextMonth()
{
QDate firstSelected = mSelectedDates.first();
int weekDay = firstSelected.dayOfWeek();
firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 );
if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
selectMonthByDate( firstSelected );
else
selectWeekByDay( weekDay, firstSelected );
}
void DateNavigator::selectNextYear()
{
QDate firstSelected = mSelectedDates.first();
int weekDay = firstSelected.dayOfWeek();
firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 );
selectWeekByDay( weekDay, firstSelected );
}
void DateNavigator::selectPrevious()
{
int offset = -7;
if ( datesCount() == 1 ) {
offset = -1;
}
if ( mViewManager )
if ( mViewManager->showsNextDays() )
offset = -datesCount();
selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
}
void DateNavigator::selectNext()
{
int offset = 7;
if ( datesCount() == 1 ) {
offset = 1;
}
if ( mViewManager )
if ( mViewManager->showsNextDays() )
offset = datesCount();
selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
}
void DateNavigator::emitSelected()
{
emit datesSelected( mSelectedDates );
}
//#include "datenavigator.moc"
diff --git a/korganizer/datenavigator.h b/korganizer/datenavigator.h
index 747e3d3..4a19e17 100644
--- a/korganizer/datenavigator.h
+++ b/korganizer/datenavigator.h
@@ -1,89 +1,90 @@
/*
This file is part of KOrganizer.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef DATENAVIGATOR_H
#define DATENAVIGATOR_H
#include <libkcal/incidencebase.h>
#include <qobject.h>
#include "koviewmanager.h"
/**
This class controls date navigation. All requests to move the views to another
date are sent to the DateNavigator. The DateNavigator processes the new
selection of dates and emits the required signals for the views.
*/
class DateNavigator : public QObject
{
Q_OBJECT
public:
DateNavigator( QObject *parent = 0, const char *name = 0 , KOViewManager * v = 0);
~DateNavigator();
KCal::DateList selectedDates();
int datesCount() const;
public slots:
void selectDates( const KCal::DateList & );
void selectDate( const QDate & );
void selectDates( int count );
void selectDates( const QDate &, int count );
void selectWeek();
void selectWeek( int weeknum );
void selectWeek( const QDate & );
void selectWorkWeek();
void selectWorkWeek( const QDate & );
void selectWeekByDay( int weekDay, const QDate & );
void selectToday();
+ void selectTodayMonth();
void selectPreviousYear();
void selectPreviousMonth();
void selectNextMonth();
void selectNextYear();
void selectMonth();
void selectMonthByDate( const QDate & );
void selectPrevious();
void selectNext();
void slotMonthSelect( int );
void slotDaySelect( QDate d );
signals:
void datesSelected( const KCal::DateList & );
protected:
void emitSelected();
private:
KOViewManager * mViewManager;
KCal::DateList mSelectedDates;
};
#endif
diff --git a/korganizer/interfaces/korganizer/baseview.h b/korganizer/interfaces/korganizer/baseview.h
index 09f8ba3..2ac9de1 100644
--- a/korganizer/interfaces/korganizer/baseview.h
+++ b/korganizer/interfaces/korganizer/baseview.h
@@ -41,152 +41,153 @@ class CalPrinter;
namespace KOrg {
class CalPrinterBase
{
public:
enum PrintType { Day, Week, Month, Todolist };
};
/**
This class provides an interface for all views being displayed within the main
calendar view. It has functions to update the view, to specify date range and
other display parameter and to return selected objects. An important class,
which inherits KOBaseView is KOEventView, which provides the interface for all
views of event data like the agenda or the month view.
@short Base class for calendar views
@author Preston Brown, Cornelius Schumacher
@see KOTodoView, KOEventView, KOListView, KOAgendaView, KOMonthView
*/
class BaseView : public QWidget
{
Q_OBJECT
public:
/**
Constructs a view.
@param cal Pointer to the calendar object from which events
will be retrieved for display.
@param parent parent widget.
@param name name of this widget.
*/
BaseView(Calendar *cal, QWidget *parent = 0, const char *name = 0) :
QWidget(parent, name), mCalendar(cal) {}
/**
Destructor. Views will do view-specific cleanups here.
*/
virtual ~BaseView() {}
/**
Return calendar object of this view.
*/
Calendar *calendar() { return mCalendar; }
/**
@return a list of selected events. Most views can probably only
select a single event at a time, but some may be able to select
more than one.
*/
virtual QPtrList<Incidence> selectedIncidences() = 0;
/**
@return a list of the dates of selected events. Most views can probably only
select a single event at a time, but some may be able to select
more than one.
*/
virtual DateList selectedDates() = 0;
/**
Generate a print preview of this event view.
@param calPrinter Calendar printer object used for printing
@param fd from date
@param td to date
*/
/*
The date parameters should be determined by the view itself and not given as
parameters. At the moment I just move the code from the topwidget to the
individual views.
*/
virtual void printPreview(CalPrinter *,
const QDate &, const QDate &)
{
KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n"
"that view yet.\n"));
}
/**
Print this view.
@param calPrinter Calendar printer object used for printing
*/
virtual void print(CalPrinter *)
{
KMessageBox::sorry(this, i18n("Unfortunately, we don't handle printing for\n"
"that view yet.\n"));
}
/**
Return number of currently shown dates. A return value of 0 means no idea.
*/
virtual int currentDateCount() = 0;
/** Return if this view is a view for displaying events. */
virtual bool isEventView() { return false; }
+ virtual bool isMonthView() { return false; }
public slots:
/**
Show incidences for the given date range. The date range actually shown may be
different from the requested range, depending on the particular requirements
of the view.
@param start Start of date range.
@param end End of date range.
*/
virtual void showDates( const QDate &start, const QDate &end ) = 0;
/**
Show given events. Depending on the actual view it might not be possible to
show all given events.
@param eventList a list of events to show.
*/
virtual void showEvents(QPtrList<Event> eventList) = 0;
/**
Updates the current display to reflect changes that may have happened
in the calendar since the last display refresh.
*/
virtual void updateView() = 0;
/**
Write all unsaved data back to calendar store.
*/
virtual void flushView() {}
/**
Updates the current display to reflect the changes to one particular event.
*/
virtual void changeEventDisplay(Event *, int) = 0;
/**
Re-reads the KOrganizer configuration and picks up relevant
changes which are applicable to the view.
*/
virtual void updateConfig() {}
/**
Clear selection. The incidenceSelected signal is not emitted.
*/
virtual void clearSelection() {}
signals:
void incidenceSelected( Incidence * );
protected:
Calendar *mCalendar;
};
}
#endif
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index d976246..e94952f 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -107,146 +107,147 @@ class MonthViewItem: public QListBoxItem
QPalette mPalette;
QDate mDate;
Incidence *mIncidence;
};
class KOMonthView;
class MonthViewCell : public QWidget
{
Q_OBJECT
public:
MonthViewCell( KOMonthView * );
void setDate( const QDate & );
QDate date() const;
void setPrimary( bool );
bool isPrimary() const;
void setHoliday( bool );
void setHoliday( const QString & );
void updateCell();
void updateConfig();
void enableScrollBars( bool );
Incidence *selectedIncidence();
QDate selectedIncidenceDate();
void deselect();
void select();
signals:
void defaultAction( Incidence * );
void newEventSignal( QDateTime );
protected:
void resizeEvent( QResizeEvent * );
protected slots:
void defaultAction( QListBoxItem * );
void contextMenu( QListBoxItem * );
void selection( QListBoxItem * );
void cellClicked( QListBoxItem * );
void newEvent();
private:
KOMonthView *mMonthView;
QDate mDate;
bool mPrimary;
bool mHoliday;
QString mHolidayString;
//QLabel *mLabel;
QPushButton *mLabel;
QListBox *mItemList;
QSize mLabelSize;
QSize mLabelBigSize;
QPalette mHolidayPalette;
QPalette mStandardPalette;
QPalette mPrimaryPalette;
QPalette mNonPrimaryPalette;
void setMyPalette();
QPalette getPalette ();
void keyPressEvent ( QKeyEvent * ) ;
};
class KOMonthView: public KOEventView
{
Q_OBJECT
public:
KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
~KOMonthView();
/** Returns maximum number of days supported by the komonthview */
virtual int maxDatesHint();
/** Returns number of currently shown dates. */
virtual int currentDateCount();
/** returns the currently selected events */
virtual QPtrList<Incidence> selectedIncidences();
/** returns dates of the currently selected events */
virtual DateList selectedDates();
virtual void printPreview(CalPrinter *calPrinter,
const QDate &, const QDate &);
+ bool isMonthView() { return true; }
MonthViewCell * selectedCell();
public slots:
virtual void updateView();
virtual void updateConfig();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void changeEventDisplay(Event *, int);
void clearSelection();
void showContextMenu( Incidence * );
void setSelectedCell( MonthViewCell * );
protected slots:
void processSelectionChange();
signals:
void selectWeekNum ( int );
protected:
void resizeEvent(QResizeEvent *);
void viewChanged();
void updateDayLabels();
private:
int mDaysPerWeek;
int mNumWeeks;
int mNumCells;
bool mWeekStartsMonday;
bool mShowSatSunComp;
void computeLayout();
QPtrVector<MonthViewCell> mCells;
QPtrVector<QLabel> mDayLabels;
QPtrVector<KOWeekButton> mWeekLabels;
bool mShortDayLabels;
int mWidthLongDayLabel;
QDate mStartDate;
MonthViewCell *mSelectedCell;
KOEventPopupMenu *mContextMenu;
void keyPressEvent ( QKeyEvent * ) ;
};
#endif