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 Qt, and distribute the resulting executable,
00022     without including the source code for Qt 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 QObject
00037 {
00038     Q_OBJECT
00039   public:
00040     DateNavigator( TQObject *parent = 0, const char *name = 0 );
00041     ~DateNavigator();
00042 
00043     KCal::DateList selectedDates();
00044 
00045     int datesCount() const;
00046 
00047   public slots:
00048     void selectDates( const KCal::DateList & );
00049     void selectDate( const TQDate & );
00050 
00051     void selectDates( int count );
00052     void selectDates( const TQDate &, int count, const TQDate &preferredMonth = TQDate() );
00053 
00054     void selectWeek();
00055     void selectWeek( const TQDate &, const TQDate &preferredMonth = TQDate() );
00056 
00057     void selectWorkWeek();
00058     void selectWorkWeek( const TQDate & );
00059 
00060     void selectWeekByDay( int weekDay, const TQDate &, const TQDate &preferredMonth = TQDate() );
00061 
00062     void selectToday();
00063 
00064     void selectPreviousYear();
00065     void selectPreviousMonth( const TQDate &currentMonth = TQDate(),
00066                               const TQDate &selectionLowerLimit = TQDate(),
00067                               const TQDate &selectionUpperLimit = TQDate() );
00068     void selectPreviousWeek();
00069     void selectNextWeek();
00070     void selectNextMonth( const TQDate &currentMonth = TQDate(),
00071                           const TQDate &selectionLowerLimit = TQDate(),
00072                           const TQDate &selectionUpperLimit = TQDate() );
00073     void selectNextYear();
00074 
00075     void selectPrevious();
00076     void selectNext();
00077 
00078     void selectMonth( int month );
00079     void selectYear( int year );
00080 
00081   signals:
00082     /* preferredMonth is useful when the datelist crosses months,
00083        if valid, any month-like component should honour it
00084     */
00085     void datesSelected( const KCal::DateList &, const TQDate &preferredMonth );
00086 
00087   protected:
00088     void emitSelected( const TQDate &preferredMonth = TQDate() );
00089 
00090   private:
00091 
00092     /*
00093       Selects next month if offset equals 1, or previous month
00094       if offset equals -1.
00095       Bigger offsets are accepted.
00096     */
00097     void shiftMonth( const TQDate &date,
00098                      const TQDate &selectionLowerLimit,
00099                      const TQDate &selectionUpperLimit,
00100                      int offset );
00101 
00102     KCal::DateList mSelectedDates;
00103 
00104     enum {
00105       MAX_SELECTABLE_DAYS = 50
00106     };
00107 };
00108 
00109 #endif