~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

« back to all changes in this revision

Viewing changes to MonthComponent.qml

  • Committer: Tarmac
  • Author(s): Kunal Parmar
  • Date: 2014-10-22 21:23:07 UTC
  • mfrom: (515.1.7 MonthCompDelegate)
  • Revision ID: tarmac-20141022212307-gyoyiqqcw6pscwom
Moved month component delegate to different file.

Approved by Ubuntu Phone Apps Jenkins Bot, Mihir Soni.

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
 
175
175
    Component{
176
176
        id: defaultDateLabelComponent
177
 
 
178
 
        Item{
179
 
            id: dateRootItem
180
 
 
181
 
            property int date: {
 
177
        MonthComponentDateDelegate{
 
178
            date: {
182
179
                //try to find date from index and month's first week's first date
183
180
                var temp = intern.daysInStartMonth - intern.offset + index
184
181
                //date exceeds days in startMonth,
196
193
                return temp;
197
194
            }
198
195
 
199
 
            property bool isCurrentMonth: {
 
196
            isCurrentMonth: {
200
197
                //remove offset from index
201
198
                //if index falls in 1 to no of days in current month
202
199
                //then date is inside current month
204
201
                return (temp >= 1 && temp <= intern.daysInCurMonth)
205
202
            }
206
203
 
207
 
            property bool isToday: intern.todayDate == date && intern.isCurMonthTodayMonth
 
204
            isToday: intern.todayDate == date && intern.isCurMonthTodayMonth
208
205
 
209
206
            width: parent.dayWidth
210
207
            height: parent.dayHeight
211
 
 
212
 
            Loader {
213
 
                width: parent.width < parent.height ? parent.width : parent.height
214
 
                height: width
215
 
                anchors.centerIn: parent
216
 
                sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
217
 
            }
218
 
 
219
 
            Label {
220
 
                id: dateLabel
221
 
                anchors.centerIn: parent
222
 
                width: parent.width
223
 
                text: date
224
 
                horizontalAlignment: Text.AlignHCenter
225
 
                fontSize: root.dateLabelFontSize
226
 
                color: {
227
 
                    if( isCurrentMonth ) {
228
 
                        if(isToday) {
229
 
                            "white"
230
 
                        } else {
231
 
                            "#5D5D5D"
232
 
                        }
233
 
                    } else {
234
 
                        "#AEA79F"
235
 
                    }
236
 
                }
237
 
            }
238
 
 
239
 
            Loader{
240
 
                property bool shouldLoad: showEvents
241
 
                                          && intern.eventStatus !== undefined
242
 
                                          && intern.eventStatus[index] !== undefined
243
 
                                          &&intern.eventStatus[index]
244
 
                sourceComponent: shouldLoad ? eventIndicatorComp : undefined
245
 
                anchors.top: dateLabel.bottom
246
 
                anchors.horizontalCenter: dateLabel.horizontalCenter
247
 
            }
248
 
 
249
 
            MouseArea {
250
 
                anchors.fill: parent
251
 
                onPressAndHold: {
252
 
                    var selectedDate = new Date();
253
 
                    selectedDate.setFullYear(intern.monthStartYear)
254
 
                    selectedDate.setMonth(intern.monthStartMonth + 1)
255
 
                    selectedDate.setDate(date)
256
 
                    selectedDate.setMinutes(60, 0, 0)
257
 
                    pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
258
 
                }
259
 
                onClicked: {
260
 
                    var selectedDate = new Date(intern.monthStartYear,
261
 
                                                intern.monthStartMonth,
262
 
                                                intern.monthStartDate + index, 0, 0, 0, 0)
263
 
                    //If monthView is clicked then open selected DayView
264
 
                    if ( isYearView === false ) {
265
 
                        root.dateSelected(selectedDate);
266
 
                    }
267
 
                    //If yearView is clicked then open selected MonthView
268
 
                    else {
269
 
                        root.monthSelected(selectedDate);
270
 
                    }
271
 
                }
272
 
            }
273
208
        }
274
209
    }
275
210