FEATURE: (contracted in prokde35)
[kdepim.git] / libkdepim / kdatepickerpopup.h
blob1e672f8258831c6521ba2f766323d21bc4dd0c68
1 /*
2 This file is part of libkdepim.
4 Copyright (c) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
21 #ifndef KDATEPICKERPOPUP_H
22 #define KDATEPICKERPOPUP_H
24 #include <QDateTime>
25 #include <QMenu>
27 #include <kdepim_export.h>
28 #include <kdatepicker.h>
30 /**
31 @short This menu helps the user to select a date quickly.
33 This menu helps the user to select a date quicly. It offers various ways of selecting, e.g. with a KDatePicker or with words like "Tomorrow".
35 The available items are:
37 @li NoDate: A menu-item with "No Date". If chosen, the datepicker will emit a null QDate.
38 @li DatePicker: Show a KDatePicker-widget.
39 @li Words: Show items like "Today", "Tomorrow" or "Next Week".
41 When supplying multiple items, separate each item with a bitwise OR.
43 @author Bram Schoenmakers <bram_s@softhome.net>
45 class KDEPIM_EXPORT KDatePickerPopup: public QMenu
47 Q_OBJECT
49 public:
50 enum ItemFlag { NoDate = 1, DatePicker = 2, Words = 4 };
52 Q_DECLARE_FLAGS( Items, ItemFlag )
54 /**
55 A constructor for the KDatePickerPopup.
57 @param items List of all desirable items, separated with a bitwise OR.
58 @param date Initial date of datepicker-widget.
59 @param parent The object's parent.
60 @param name The object's name.
62 KDatePickerPopup( Items items = DatePicker, const QDate &date = QDate::currentDate(),
63 QWidget *parent = 0 );
65 /**
66 @return A pointer to the private variable mDatePicker, an instance of
67 KDatePicker.
69 KDatePicker *datePicker() const;
71 void setDate( const QDate &date );
73 #if 0
74 /** Set items which should be shown and rebuilds the menu afterwards. Only if the menu is not visible.
75 @param items List of all desirable items, separated with a bitwise OR.
77 void setItems( int items = 1 );
78 #endif
79 /** @return Returns the bitwise result of the active items in the popup. */
80 int items() const { return mItems; }
82 signals:
84 /**
85 This signal emits the new date (selected with datepicker or other
86 menu-items).
88 void dateChanged ( const QDate& );
90 protected slots:
91 void slotDateChanged ( const QDate& );
93 void slotToday();
94 void slotTomorrow();
95 void slotNextWeek();
96 void slotNextMonth();
97 void slotNoDate();
99 private:
100 void buildMenu();
102 KDatePicker *mDatePicker;
103 Items mItems;
106 Q_DECLARE_OPERATORS_FOR_FLAGS( KDatePickerPopup::Items )
108 #endif