korganizer

datenavigator.h
00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
00004     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of TQt, and distribute the resulting executable,
00022     without including the source code for TQt in the source distribution.
00023 */
00024 #ifndef DATENAVIGATOR_H
00025 #define DATENAVIGATOR_H
00026 
00027 #include <libkcal/incidencebase.h>
00028 
00029 #include <tqobject.h>
00030 
00036 class DateNavigator : public TQObject
00037 {
00038     Q_OBJECT
00039   TQ_OBJECT
00040   public:
00041     DateNavigator( TQObject *parent = 0, const char *name = 0 );
00042     ~DateNavigator();
00043 
00044     KCal::DateList selectedDates();
00045 
00046     int datesCount() const;
00047 
00048   public slots:
00049     void selectDates( const KCal::DateList & );
00050     void selectDate( const TQDate & );
00051 
00052     void selectDates( int count );
00053     void selectDates( const TQDate &, int count, const TQDate &preferredMonth = TQDate() );
00054 
00055     void selectWeek();
00056     void selectWeek( const TQDate &, const TQDate &preferredMonth = TQDate() );
00057 
00058     void selectWorkWeek();
00059     void selectWorkWeek( const TQDate & );
00060 
00061     void selectWeekByDay( int weekDay, const TQDate &, const TQDate &preferredMonth = TQDate() );
00062 
00063     void selectToday();
00064 
00065     void selectPreviousYear();
00066     void selectPreviousMonth( const TQDate &currentMonth = TQDate(),
00067                               const TQDate &selectionLowerLimit = TQDate(),
00068                               const TQDate &selectionUpperLimit = TQDate() );
00069     void selectPreviousWeek();
00070     void selectNextWeek();
00071     void selectNextMonth( const TQDate &currentMonth = TQDate(),
00072                           const TQDate &selectionLowerLimit = TQDate(),
00073                           const TQDate &selectionUpperLimit = TQDate() );
00074     void selectNextYear();
00075 
00076     void selectPrevious();
00077     void selectNext();
00078 
00079     void selectMonth( int month );
00080     void selectYear( int year );
00081 
00082   signals:
00083     /* preferredMonth is useful when the datelist crosses months,
00084        if valid, any month-like component should honour it
00085     */
00086     void datesSelected( const KCal::DateList &, const TQDate &preferredMonth );
00087 
00088   protected:
00089     void emitSelected( const TQDate &preferredMonth = TQDate() );
00090 
00091   private:
00092 
00093     /*
00094       Selects next month if offset equals 1, or previous month
00095       if offset equals -1.
00096       Bigger offsets are accepted.
00097     */
00098     void shiftMonth( const TQDate &date,
00099                      const TQDate &selectionLowerLimit,
00100                      const TQDate &selectionUpperLimit,
00101                      int offset );
00102 
00103     KCal::DateList mSelectedDates;
00104 
00105     enum {
00106       MAX_SELECTABLE_DAYS = 50
00107     };
00108 };
00109 
00110 #endif