* Fixes for pathview date component (slowly in date switching)
[lichviet] / qml / LichViet / main.qml
index 565b3ad..1c7eb47 100644 (file)
@@ -113,8 +113,8 @@ Item {
 
                   Rectangle {
                       id:reelx
-                      width: 300
-                      height: 100
+                      width: 260
+                      height: 90
                       y: 116
                       anchors.horizontalCenter: parent.horizontalCenter
                       property int index: 0
@@ -158,15 +158,30 @@ Item {
                           delegate: delegate
                           pathItemCount: 3
                           clip: true
+                          highlightMoveDuration:500
+                          Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
+                          Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
                           preferredHighlightBegin: 0.5
                           preferredHighlightEnd: 0.5
                           highlightRangeMode: PathView.StrictlyEnforceRange
                           focus: true
+                          interactive: true
+                          highlight: Rectangle{
+                              anchors.topMargin: 10;
+                              width:110;
+                              height:80;
+                              radius: 8;
+                              color:"#000000"
+                              opacity: 0.3
+                          }
                           path: Path {
                               startX: 0
                               startY: 50
                               PathLine {x: reelx.width; y: 50}
                           }
+                          onFlickEnded : {
+                          }
+
                           onMovementEnded: {
                               calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear())
                           }
@@ -176,19 +191,43 @@ Item {
                       id:maindatemodel
 
                       function reset(){
+                          var days_of_this_month = LC.calDays(screen.curMonth,screen.curYear);
+                          var days_of_changes = days_of_this_month - maindatemodel.count;
+
+                          var ifs;
+
+                          if (days_of_changes<0){
+                              ifs=Math.abs(days_of_changes);
+                              while(ifs>0){
+                                  maindatemodel.remove(maindatemodel.count-1);
+                                  ifs-=1;
+                              }
+                          }else if(days_of_changes>0){
+                              ifs=maindatemodel.count;
+                              for (var i=1;i<=days_of_changes;i++)
+                                  append({name:i+ifs})
+                          }
+
+                         reelx.index = -1; // I dont now why must be added -1 before screen.curDay-1
+                         reelx.index = screen.curDay-1;
+
+                      }
+
+                      function init(){
                           while(maindatemodel.count>0){
                               try{maindatemodel.remove(maindatemodel.count-1)}catch(e){}
                           }
 
                           for(var i=1;i<=LC.calDays(screen.curMonth,screen.curYear);i++)
                               append({name:i})
+
                           reelx.index = screen.curDay -1
                       }
                   }
 
          //-------------------------------------------------
                   Component.onCompleted: {
-                     maindatemodel.reset()
+                     maindatemodel.init()
                   }
 
          Text {
@@ -330,6 +369,13 @@ Item {
 
      states: [
          State {
+             name:"mainscreen"
+             StateChangeScript {
+                 script:{
+                 }
+                }
+         },
+         State {
              name: "menuscreen";
              PropertyChanges { target: menuScreen; x: 0; focus:true}
              PropertyChanges { target: toolBar; y: screen.height }
@@ -457,6 +503,7 @@ Item {
      }
 
      function refresh(){
+
      }
 
      Component.onCompleted: {