@@ -4,64 +4,118 @@ import QtQuick.Controls 2.15
44import  "qrc:/qml/" 
55
66// CalendarGrid.qml 
7- GridLayout  {
8-     id:  calendarGrid
9-     columns:  7 
10-     rowSpacing:  0 
11-     columnSpacing:  0 
7+ ColumnLayout  {
8+     id:  calendarGridRoot
129    Layout .fillWidth :  true 
13-     Layout .fillHeight :  true 
14-     Layout .margins :  20 
15-     Layout .topMargin :  10 
1610
11+     //  Properties
1712    property alias calendarModel:  repeater .model 
13+     property alias eventListModel:  eventLabel .eventModel 
1814    property var  theme
1915
16+     //  Signals
2017    signal dayClicked (var  panchanga)
2118
22-     Repeater {
23-         id:  repeater
24-         delegate:  Item {
25-             Layout .fillWidth :  true 
26-             Layout .fillHeight :  modelData .type  ===  " day" ||  modelData .type  ===  " empty" 
27-             Layout .preferredHeight :  modelData .type  ===  " header" ?  35  :  - 1 
19+     //  Components
2820
29-             Loader {
30-                 id:  delegateLoader
31-                 anchors .fill :  parent
21+     //  Calendar grid layout
22+     GridLayout {
23+         id:  calendarGrid
24+         columns:  7 
25+         rowSpacing:  0 
26+         columnSpacing:  0 
27+         Layout .fillWidth :  true 
28+         Layout .preferredHeight :  parent .width 
29+         Layout .margins :  10 
30+         Layout .topMargin :  10 
31+         // Layout.bottomMargin: 10
32+ 
33+         Repeater {
34+             id:  repeater
35+             delegate:  Item {
36+                 Layout .fillWidth :  true 
37+                 Layout .fillHeight :  modelData .type  ===  " day" ||  modelData .type  ===  " empty" 
38+                 Layout .preferredHeight :  modelData .type  ===  " header" ?  35  :  - 1 
39+ 
40+                 Loader {
41+                     id:  delegateLoader
42+                     anchors .fill :  parent
3243
33-                 sourceComponent:  {
34-                     if  (modelData .type  ===  " header" 
35-                         return  headerComponent;
36-                     } else  if  (modelData .type  ===  " day" 
37-                         return  dayComponent;
38-                     } else  { //  for "empty" type
39-                         return  emptyComponent;
44+                     sourceComponent:  {
45+                         if  (modelData .type  ===  " header" 
46+                             return  headerComponent;
47+                         } else  if  (modelData .type  ===  " day" 
48+                             return  dayComponent;
49+                         } else  {
50+                             return  emptyComponent;
51+                         }
52+                     }
53+ 
54+                     onLoaded:  {
55+                         if  (modelData .type  ===  " day" 
56+                             item .bsDay  =  modelData .bsDay ;
57+                             item .adDay  =  modelData .adDay ;
58+                             item .tithi  =  modelData .tithi ;
59+                             item .isToday  =  modelData .isToday ;
60+                             item .isSaturday  =  modelData .isSaturday ;
61+                             item .hasEvent  =  modelData .hasEvent ;
62+                             item .theme  =  calendarGridRoot .theme ;
63+                             item .clicked .connect (function () {
64+                                 calendarGridRoot .dayClicked (modelData .panchanga )
65+                             });
66+                         } else  if  (modelData .type  ===  " header" 
67+                             item .text  =  modelData .text ;
68+                             item .theme  =  calendarGridRoot .theme ;
69+                             item .cellIndex  =  index;
70+                         }
4071                    }
4172                }
73+             }
74+         }
75+     }
76+ 
77+     //  Event List Footer
78+     Rectangle {
79+         id:  eventFooter
80+         Layout .fillWidth :  true 
81+         // Layout.topMargin: 10
82+         implicitHeight:  eventLabel .paintedHeight  +  20 
83+         color:  theme .secondaryBg 
84+         radius:  6 
85+         visible:  eventLabel .eventModel  &&  eventLabel .eventModel .length  >  0 
4286
43-                 onLoaded:  {
44-                     if  (modelData .type  ===  " day" 
45-                         item .bsDay  =  modelData .bsDay ;
46-                         item .adDay  =  modelData .adDay ;
47-                         item .tithi  =  modelData .tithi ;
48-                         item .isToday  =  modelData .isToday ;
49-                         item .isSaturday  =  modelData .isSaturday ;
50-                         item .theme  =  calendarGrid .theme ;
51-                         item .clicked .connect (function () {
52-                             calendarGrid .dayClicked (modelData .panchanga )
53-                         });
54-                     } else  if  (modelData .type  ===  " header" 
55-                         item .text  =  modelData .text ;
56-                         item .theme  =  calendarGrid .theme ;
57-                         item .cellIndex  =  index;
87+         Label {
88+             id:  eventLabel
89+             anchors .fill :  parent
90+             anchors .margins :  10 
91+ 
92+             property var  eventModel:  [] //  Model reference
93+ 
94+             //  Bind the text property to a function that builds the string
95+             text:  {
96+                 var  str =  " " 
97+                 if  (eventModel) {
98+                     for  (var  i =  0 ; i <  eventModel .length ; i++ ) {
99+                         var  item =  eventModel[i];
100+                         str +=  item .bsDay  +  "  :\u00A0 " +  item .eventName ;
101+                         if  (i <  eventModel .length  -  1 ) {
102+                             str +=  "   •  " 
103+                         }
58104                    }
59105                }
106+                 return  str;
60107            }
108+ 
109+             font .pixelSize :  14 
110+             color:  theme ?  theme .secondaryText  :  " black" 
111+             wrapMode:  Text .WordWrap 
112+             horizontalAlignment:  Text .AlignHCenter 
113+             verticalAlignment:  Text .AlignVCenter 
61114        }
62115    }
63116
64117
118+     //  Component Definitions
65119    Component {
66120        id:  headerComponent
67121        Item {
@@ -78,56 +132,15 @@ GridLayout {
78132                border .color :  theme .borderColor 
79133            }
80134
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-             }
135+             Rectangle { visible:  cellIndex ===  0 ; width:  headerBackground .radius ; height:  headerBackground .radius ; color:  headerBackground .color ; anchors .top :  parent .top ; anchors .right :  parent .right  }
136+             Rectangle { visible:  cellIndex ===  0 ; width:  headerBackground .radius ; height:  headerBackground .radius ; color:  headerBackground .color ; anchors .bottom :  parent .bottom ; anchors .left :  parent .left  }
137+             Rectangle { visible:  cellIndex ===  6 ; width:  headerBackground .radius ; height:  headerBackground .radius ; color:  headerBackground .color ; anchors .top :  parent .top ; anchors .left :  parent .left  }
138+             Rectangle { visible:  cellIndex ===  6 ; width:  headerBackground .radius ; height:  headerBackground .radius ; color:  headerBackground .color ; anchors .bottom :  parent .bottom ; anchors .left :  parent .left  }
139+             Rectangle { visible:  cellIndex ===  0  ||  cellIndex ===  6 ; width:  headerBackground .radius ; height:  headerBackground .radius ; color:  headerBackground .color ; anchors .bottom :  parent .bottom ; anchors .right :  parent .right  }
121140
122141            Label {
123142                text:  headerItemContainer .text 
124-                 color:  {
125-                     if  (cellIndex ===  6 ) {
126-                         return  " #E4080A" 
127-                     } else  {
128-                         return  theme .accentText ;
129-                     }
130-                 }
143+                 color:  (cellIndex ===  6 ) ?  " #E4080A" :  theme .accentText 
131144                font .bold :  true 
132145                font .pixelSize :  14 
133146                anchors .centerIn :  parent
0 commit comments