@@ -7,8 +7,8 @@ import "qrc:/qml/"
77GridLayout  {
88    id:  calendarGrid
99    columns:  7 
10-     rowSpacing:  8 
11-     columnSpacing:  8 
10+     rowSpacing:  0 
11+     columnSpacing:  0 
1212    Layout .fillWidth :  true 
1313    Layout .fillHeight :  true 
1414    Layout .margins :  20 
@@ -26,13 +26,10 @@ GridLayout {
2626            Layout .fillHeight :  modelData .type  ===  " day" ||  modelData .type  ===  " empty" 
2727            Layout .preferredHeight :  modelData .type  ===  " header" ?  35  :  - 1 
2828
29-             //  Use a Loader to conditionally instantiate the correct component.
30-             //  This is the key to fixing the "Unable to assign [undefined]" errors.
3129            Loader {
3230                id:  delegateLoader
3331                anchors .fill :  parent
3432
35-                 //  Set the source component based on the model data type
3633                sourceComponent:  {
3734                    if  (modelData .type  ===  " header" 
3835                        return  headerComponent;
@@ -43,7 +40,6 @@ GridLayout {
4340                    }
4441                }
4542
46-                 //  After the correct component is loaded, set its specific properties.
4743                onLoaded:  {
4844                    if  (modelData .type  ===  " day" 
4945                        item .bsDay  =  modelData .bsDay ;
@@ -52,53 +48,104 @@ GridLayout {
5248                        item .isToday  =  modelData .isToday ;
5349                        item .isSaturday  =  modelData .isSaturday ;
5450                        item .theme  =  calendarGrid .theme ;
55-                         //  Connect the signal from the loaded DayCell to the CalendarGrid's signal
5651                        item .clicked .connect (function () {
5752                            calendarGrid .dayClicked (modelData .panchanga )
5853                        });
5954                    } else  if  (modelData .type  ===  " header" 
6055                        item .text  =  modelData .text ;
6156                        item .theme  =  calendarGrid .theme ;
57+                         item .cellIndex  =  index;
6258                    }
6359                }
6460            }
6561        }
6662    }
6763
68-     //  --- Component Definitions for the Loader ---
6964
7065    Component {
7166        id:  headerComponent
72-         Rectangle  {
73-             //  These properties are set by the Loader 
67+         Item  {
68+             id :  headerItemContainer 
7469            property string text
7570            property var  theme
71+             property int cellIndex:  - 1 
72+ 
73+             Rectangle {
74+                 id:  headerBackground
75+                 anchors .fill :  parent
76+                 radius:  (cellIndex ===  0  ||  cellIndex ===  6 ) ?  6  :  0 
77+                 color:  theme ?  theme .secondaryBg  :  " #FFFFFF" 
78+                 border .color :  theme .borderColor 
79+             }
7680
77-             radius:  8 
78-             color:  theme &&  theme .isDark  ?  theme .secondaryBg  :  (theme ?  theme .tertiaryBg  :  " lightgrey" 
79-             border .width :  0 
81+             Rectangle {
82+                 visible:  cellIndex ===  0 
83+                 width:  headerBackground .radius 
84+                 height:  headerBackground .radius 
85+                 color:  headerBackground .color 
86+                 anchors .top :  parent .top 
87+                 anchors .right :  parent .right 
88+             }
89+             Rectangle {
90+                 visible:  cellIndex ===  0 
91+                 width:  headerBackground .radius 
92+                 height:  headerBackground .radius 
93+                 color:  headerBackground .color 
94+                 anchors .bottom :  parent .bottom 
95+                 anchors .left :  parent .left 
96+             }
97+             Rectangle {
98+                 visible:  cellIndex ===  6 
99+                 width:  headerBackground .radius 
100+                 height:  headerBackground .radius 
101+                 color:  headerBackground .color 
102+                 anchors .top :  parent .top 
103+                 anchors .left :  parent .left 
104+             }
105+             Rectangle {
106+                 visible:  cellIndex ===  6 
107+                 width:  headerBackground .radius 
108+                 height:  headerBackground .radius 
109+                 color:  headerBackground .color 
110+                 anchors .bottom :  parent .bottom 
111+                 anchors .left :  parent .left 
112+             }
113+             Rectangle {
114+                 visible:  cellIndex ===  0  ||  cellIndex ===  6 
115+                 width:  headerBackground .radius 
116+                 height:  headerBackground .radius 
117+                 color:  headerBackground .color 
118+                 anchors .bottom :  parent .bottom 
119+                 anchors .right :  parent .right 
120+             }
80121
81122            Label {
82-                 text:  parent .text 
83-                 color:  theme &&  theme .isDark  ?  theme .secondaryText  :  (theme ?  theme .accentText  :  " blue" 
123+                 text:  headerItemContainer .text 
124+                 color:  {
125+                     if  (cellIndex ===  6 ) {
126+                         return  " #E4080A" 
127+                     } else  {
128+                         return  theme .accentText ;
129+                     }
130+                 }
84131                font .bold :  true 
85-                 font .pixelSize :  12 
86-                 anchors .fill :  parent
87-                 horizontalAlignment:  Text .AlignHCenter 
88-                 verticalAlignment:  Text .AlignVCenter 
132+                 font .pixelSize :  14 
133+                 anchors .centerIn :  parent
89134            }
90135        }
91136    }
92137
93138    Component {
94139        id:  dayComponent
95-         //  The DayCell itself. Its properties will be set by the Loader's onLoaded handler.
96140        DayCell {}
97141    }
98142
99143    Component {
100144        id:  emptyComponent
101-         //  An empty item for the blank days at the start of the month.
102-         Item {}
145+         Rectangle {
146+             border .color :  theme ?  theme .borderColor  :  " grey" 
147+             border .width :  1 
148+             color:  " transparent" 
149+         }
103150    }
104151}
0 commit comments