(Difference between revisions)
|
|
| Line 23: |
Line 23: |
| | ;''bool'' isDateInRange | | ;''bool'' isDateInRange |
| | :True if the selected date is in range of the min and max values. | | :True if the selected date is in range of the min and max values. |
| - |
| |
| - | =Private properties=
| |
| - | ;''list<string>'' daysOfWeek
| |
| - | :Contains the names of the days in a week.
| |
| - | ;''list<string>'' shortMonths
| |
| - | :Contains the names of the months shortened to the first three characters.
| |
| - | ;''list<string>'' fullMonths
| |
| - | :Contains the full names of the months.
| |
| - | ;''variant'' dayModel
| |
| - | :Contains a listModel for the days.
| |
| - | ;''variant'' monthModel
| |
| - | :Contains a listModel for the months.
| |
| - | ;''variant'' yearModel
| |
| - | :Contains a listModel for the years.
| |
| - | ;''variant'' oldDate
| |
| - | :Stores the date which was selected when the dialog is shown to restore it on cancel.
| |
| - | ;''int'' day
| |
| - | :Used to initialize the day spinner.
| |
| - | ;''int'' month
| |
| - | :Used to initialize the month spinner.
| |
| - | ;''int'' year
| |
| - | :Used to initialize the year spinner.
| |
| - | ;''bool'' isFuture
| |
| - | :True if the currently selected date is in the future.
| |
| - | ;''bool'' isPast
| |
| - | :True if the currently selected date is in the past.
| |
| | | | |
| | =Signals= | | =Signals= |
Revision as of 12:29, 28 April 2011
Description
Displays control elements to choose a date by day, month and year. The values can either be chosen using the three PopupLists at the top or by the calender grid in the center. The min... and max... properties can be used to restrict the chosable date to a specific date. Selecting a date outside that range will disable the ok button. Make sure valid values for min and max are set, otherwise the DatePicker might not work as expected.
API properties
- variant selectedDate
- Contains the currently selected date.
- int startYear
- Sets the first year available in the year spinner, needs a positive value smaller or equal to endYear.
- int endYear
- Sets the last year available in the year spinner, needs a positive value bigger or equal to startYear.
- int minYear
- Sets the first selectable year, needs a positive value smaller or equal to maxYear.
- int minMonth
- Sets the first selectable month, needs a value from 1 to 12.
- int minDay
- Sets the first selectable day, needs a value from 1 to 31.
- int maxYear
- Sets the last selectable year, needs a positive value bigger or equal to minYear.
- int maxMonth
- Sets the last selectable month, needs a value from 1 to 12.
- int maxDay
- Sets the last selectable day, needs a value from 1 to 31.
- bool isDateInRange
- True if the selected date is in range of the min and max values.
Signals
- dateSelected
- Emitted when ok button is clicked, propagates the selected date.
- Parameters:
- variant date, a java Date object.
Functions
- show
- Fades the picker in, inherited from ModalFog.
- hide
- Fades the picker out, inherited from ModalFog.
- today
- Returns the current date, internal use only.
- Return value:
- variant date, the current date
- isCurrentDate
- Returns true if parameter date matches the current date, internal use only.
- Parameters:
- Date date, a java date object.
- Return value:
- bool, true if the parameter date matches the current date
- startDay
- Returns the first day of month mm in year yyyy, internal use only.
- Parameters:
- int mm, the month
- int yyyy, the year
- Return value:
- int, the first day of the given month and year
- daysInMonth
- Returns the number of days of month mm in year yyyy, internal use only.
- Parameter:
- int mm, the month
- int yyyy, the month
- Return value:
- int, the number of days in the given month and year
- isSelectedDate
- Returns true if the currently selected date is dd-mm-yyyy, internal use only.
- Parameters:
- int dd, the day
- int mm, the month
- int yyyy, the year
- Return value:
- bool, true if the currently selected date matches the given date
- nexthMonth
- Returns the index of the following month, internal use only.
- Parameters:
- Date refDate, java Date object
- Return value:
- int the index of the following month
- prevMonth
- Returns the index of the former month, internal use only.
- Parameters:
- Date refDate, a java Date
- Return value:
- int, the index of the former month
- setFuturePast
- Checks if the currently selected date is in the future or the past and sets the properties isFuture and isPast accordingly.
- updateSelectedDate
- Updates the day model if necessary, updates the spinners and sets the selected date.
- Parameter:
- int d, the new day
- int m, the new month
- int y, the new year
- setDays
- Updates the selected day.
- Parameters:
- int d, the new day
- int m, the new month
- int y, the new year
- changeDayModel
- Updates the day model if necessary.
- Parameters:
- int d, the new day
- int m, the new month
- int y, the new year
- updateYears
- Called when minYear or maxYear have been changed. Updates the year model to contain only the years from minYear to maxYear and sets the selected year into that range if needed. At the end updateSelectedDate is called to propagate the new date and selection.
- checkSelectedDate
- Checks if the given date is in the range given by the properties minYear, minMonth, minDay, maxYear, maxMonth and maxDay
- Parameters:
- int d, the given day
- int m, the given month
- int y, the given year
Example
//a button labeled with the selected date
Button {
id: dateButton
DatePicker {
id: datePicker
onDateSelected: {
dateButton.text = //TODO: where does Date come from?
}
}
onClicked: {
datePicker.show()
}
}