Warning, file /office/skrooge/skgbasegui/kdatepickerpopup.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002   This file is part of libkdepim.
0003 
0004   Copyright (c) 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
0005 
0006   This library is free software; you can redistribute it and/or
0007   modify it under the terms of the GNU Library General Public
0008   License as published by the Free Software Foundation; either
0009   version 2 of the License, or (at your option) any later version.
0010 
0011   This library is distributed in the hope that it will be useful,
0012   but WITHOUT ANY WARRANTY; without even the implied warranty of
0013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014   Library General Public License for more details.
0015 
0016   You should have received a copy of the GNU Library General Public License
0017   along with this library; see the file COPYING.LIB.  If not, write to
0018   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019   Boston, MA 02110-1301, USA.
0020 */
0021 #ifndef KDEPIM_KDATEPICKERPOPUP_H
0022 #define KDEPIM_KDATEPICKERPOPUP_H
0023 
0024 #include <qdatetime.h>
0025 #include <qmenu.h>
0026 
0027 class KDatePicker;
0028 
0029 namespace KPIM
0030 {
0031 
0032 /**
0033    @short This menu helps the user to select a date quickly.
0034 
0035    This menu helps the user to select a date quicly. It offers various
0036    ways of selecting, e.g. with a KDatePicker or with words like "Tomorrow".
0037 
0038    The available items are:
0039 
0040    @li NoDate: A menu-item with "No Date". If chosen, the datepicker will emit
0041        a null QDate.
0042    @li DatePicker: Show a KDatePicker-widget.
0043    @li Words: Show items like "Today", "Tomorrow" or "Next Week".
0044 
0045    When supplying multiple items, separate each item with a bitwise OR.
0046 
0047    @author Bram Schoenmakers <bram_s@softhome.net>
0048 */
0049 class KDatePickerPopup: public QMenu
0050 {
0051     Q_OBJECT
0052 
0053 public:
0054     enum ItemFlag {
0055         NoDate = 1,
0056         DatePicker = 2,
0057         Words = 4
0058     };
0059 
0060     Q_DECLARE_FLAGS(Items, ItemFlag)
0061 
0062     /**
0063        A constructor for the KDatePickerPopup.
0064        @param iItems List of all desirable items, separated with a bitwise OR.
0065        @param iDate Initial date of datepicker-widget.
0066        @param iParent The object's parent.
0067     */
0068     // cppcheck-suppress passedByValue
0069     explicit KDatePickerPopup(Items iItems = KDatePickerPopup::NoDate,
0070                               QDate iDate = QDate::currentDate(),
0071                               QWidget* iParent = nullptr);
0072 
0073     /**
0074        @return A pointer to the private variable mDatePicker, an instance of
0075        KDatePicker.
0076     */
0077     KDatePicker* datePicker() const;
0078 
0079     // cppcheck-suppress passedByValue
0080     void setDate(QDate date);
0081 
0082 #if 0
0083     /** Set items which should be shown and rebuilds the menu afterwards.
0084         Only if the menu is not visible.
0085         @param items List of all desirable items, separated with a bitwise OR.
0086     */
0087     void setItems(int items = 1);
0088 #endif
0089     /** @return Returns the bitwise result of the active items in the popup. */
0090     int items() const
0091     {
0092         return mItems;
0093     }
0094 
0095 Q_SIGNALS:
0096 
0097     /**
0098       This signal emits the new date (selected with datepicker or other
0099       menu-items).
0100     */
0101     // cppcheck-suppress passedByValue
0102     void dateChanged(QDate date);
0103 
0104 protected Q_SLOTS:
0105     // cppcheck-suppress passedByValue
0106     void slotDateChanged(QDate date);
0107 
0108     void slotYesterday();
0109     void slotToday();
0110     void slotTomorrow();
0111     void slotNextWeek();
0112     void slotNextMonth();
0113     void slotNoDate();
0114 
0115 private:
0116     void buildMenu();
0117 
0118     KDatePicker* mDatePicker;
0119     Items mItems;
0120 };
0121 
0122 Q_DECLARE_OPERATORS_FOR_FLAGS(KDatePickerPopup::Items)
0123 
0124 } // namespace KPIM
0125 
0126 #endif
0127