/usr/include/kdatecombobox.h is in kdelibs5-dev 4:4.14.38-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | /*
Copyright 2011 John Layt <john@layt.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KDATECOMBOBOX_H
#define KDATECOMBOBOX_H
#include <kdeui_export.h>
#include <QtGui/QWidget>
#include "kcombobox.h"
#include "klocale.h"
#include "kdatetime.h"
class KDateComboBoxPrivate;
class KCalendarSystem;
class KDEUI_EXPORT KDateComboBox : public KComboBox
{
Q_OBJECT
Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true)
Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET resetMinimumDate)
Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET resetMaximumDate)
Q_PROPERTY(Options options READ options WRITE setOptions)
Q_FLAGS(Options)
public:
/**
* Options provided by the widget
* @see options()
* @see setOptions()
*/
enum Option {
EditDate = 0x0001, /**< Allow the user to manually edit the date in the combo line edit */
SelectDate = 0x0002, /**< Allow the user to select the date from a drop-down menu */
DatePicker = 0x0004, /**< Show a date picker in the drop-down */
DateKeywords = 0x0008, /**< Show date keywords in the drop-down */
WarnOnInvalid = 0x0010 /**< Show a warning on focus out if the date is invalid */
};
Q_DECLARE_FLAGS(Options, Option)
/**
* Create a new KDateComboBox widget
*
* By default the EditDate, SelectDate, DatePicker and DateKeywords options
* are enabled, the ShortDate format is used and the date is set to the
* current date.
*/
explicit KDateComboBox(QWidget *parent = 0);
/**
* Destroy the widget
*/
virtual ~KDateComboBox();
/**
* Return the currently selected date
*
* @return the currently selected date
*/
QDate date() const;
/**
* Returns the Calendar System type used by the widget
*
* @see KLocale::CalendarSystem
* @see setCalendarSystem()
* @return the Calendar System currently used
*/
KLocale::CalendarSystem calendarSystem() const;
/**
* Returns a pointer to the Calendar System object used by this widget
*
* Usually this will be the Global Calendar System using the Global Locale,
* but this may have been changed to a custom Calendar System possibly
* using a custom Locale.
*
* Normally you will not need to access this object.
*
* @see KCalendarSystem
* @see setCalendar
* @return the current calendar system instance
*/
const KCalendarSystem *calendar() const;
/**
* Return if the current user input is valid
*
* If the user input is null then it is not valid
*
* @see isNull()
* @return if the current user input is valid
*/
bool isValid() const;
/**
* Return if the current user input is null
*
* @see isValid()
* @return if the current user input is null
*/
bool isNull() const;
/**
* Return the currently set widget options
*
* @return the currently set widget options
*/
Options options() const;
/**
* Return the currently set date display format
*
* By default this is the Short Date
*
* @return the currently set date format
*/
KLocale::DateFormat displayFormat() const;
/**
* Return the current minimum date
*
* @return the current minimum date
*/
QDate minimumDate() const;
/**
* Return the current maximum date
*
* @return the current maximum date
*/
QDate maximumDate() const;
/**
* Return the map of dates listed in the drop-down and their displayed
* string forms.
*
* @see setDateMap()
* @return the select date map
*/
QMap<QDate, QString> dateMap() const;
Q_SIGNALS:
/**
* Signal if the date has been manually entered or selected by the user.
*
* The returned date may be invalid.
*
* @param date the new date
*/
void dateEntered(const QDate &date);
/**
* Signal if the date has been changed either manually by the user
* or programatically.
*
* The returned date may be invalid.
*
* @param date the new date
*/
void dateChanged(const QDate &date);
/**
* Signal if the date is being manually edited by the user.
*
* The returned date may be invalid.
*
* @param date the new date
*/
void dateEdited(const QDate &date);
public Q_SLOTS:
/**
* Set the currently selected date
*
* You can set an invalid date or a date outside the valid range, validity
* checking is only done via isValid().
*
* @param date the new date
*/
void setDate(const QDate &date);
/**
* Set the Calendar System used for this widget. Uses the global locale.
*
* @see KLocale::CalendarSystem
* @see calendarSystem()
* @param calendarSystem the Calendar System to use
*/
void setCalendarSystem(KLocale::CalendarSystem calendarSystem);
/**
* Changes the calendar system to use. Can use its own local locale if set.
*
* You retain ownership of the calendar object, it will not be destroyed with the widget.
*
* @param calendar the calendar system object to use, defaults to global
*/
void setCalendar(KCalendarSystem *calendar = 0);
/**
* Set the new widget options
*
* @param options the new widget options
*/
void setOptions(Options options);
/**
* Sets the date format to display.
*
* By default is the Short Date format.
*
* @param format the date format to use
*/
void setDisplayFormat(KLocale::DateFormat format);
/**
* Set the valid date range to be applied by isValid().
*
* Both dates must be valid and the minimum date must be less than or equal
* to the maximum date, otherwise the date range will not be set.
*
* @param minDate the minimum date
* @param maxDate the maximum date
* @param minWarnMsg the minimum warning message
* @param maxWarnMsg the maximum warning message
*/
void setDateRange(const QDate &minDate,
const QDate &maxDate,
const QString &minWarnMsg = QString(),
const QString &maxWarnMsg = QString());
/**
* Reset the minimum and maximum date to the default values.
* @see setDateRange()
*/
void resetDateRange();
/**
* Set the minimum allowed date.
*
* If the date is invalid, or greater than current maximum,
* then the minimum will not be set.
*
* @see minimumDate()
* @see maximumDate()
* @see setMaximumDate()
* @see setDateRange()
* @param minDate the minimum date
* @param minWarnMsg the minimum warning message
*/
void setMinimumDate(const QDate &minTime, const QString &minWarnMsg = QString());
/**
* Reset the minimum date to the default
*/
void resetMinimumDate();
/**
* Set the maximum allowed date.
*
* If the date is invalid, or less than current minimum,
* then the maximum will not be set.
*
* @see minimumDate()
* @see maximumDate()
* @see setMaximumDate()
* @see setDateRange()
* @param maxDate the maximum date
* @param maxWarnMsg the maximum warning message
*/
void setMaximumDate(const QDate &maxDate, const QString &maxWarnMsg = QString());
/**
* Reset the maximum date to the default
*/
void resetMaximumDate();
/**
* Set the list of dates able to be selected from the drop-down and the
* string form to display for those dates, e.g. "2010-01-01" and "Yesterday".
*
* Any invalid or duplicate dates will be used, the list will NOT be
* sorted, and the minimum and maximum date will not be affected.
*
* The @p dateMap is keyed by the date to be listed and the value is the
* string to be displayed. If you want the date to be displayed in the
* default date format then the string should be null. If you want a
* separator to be displayed then set the string to "seperator".
*
* @see dateMap()
* @param dateMap the map of dates able to be selected
*/
void setDateMap(QMap<QDate, QString> dateMap);
protected:
virtual bool eventFilter(QObject *object, QEvent *event);
virtual void showPopup();
virtual void hidePopup();
virtual void mousePressEvent(QMouseEvent *event);
virtual void wheelEvent(QWheelEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void focusInEvent(QFocusEvent *event);
virtual void focusOutEvent(QFocusEvent *event);
virtual void resizeEvent(QResizeEvent *event);
/**
* Assign the date for the widget.
*
* Virtual to allow sub-classes to apply extra validation rules.
*
* @param date the new date
*/
virtual void assignDate(const QDate &date);
/**
* Assign the calendar system for the widget.
*
* Virtual to allow sub-classes to apply extra validation rules.
*
* @param time the new time
*/
virtual void assignCalendarSystem(KLocale::CalendarSystem calendarSystem);
private:
friend class KDateComboBoxPrivate;
KDateComboBoxPrivate *const d;
Q_PRIVATE_SLOT(d, void clickDate())
Q_PRIVATE_SLOT(d, void selectDate(QAction*))
Q_PRIVATE_SLOT(d, void editDate(const QString&))
Q_PRIVATE_SLOT(d, void enterDate(const QDate&))
Q_PRIVATE_SLOT(d, void parseDate())
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KDateComboBox::Options)
#endif // KDATECOMBOBOX_H
|