Advertisement
vavan_bonus

work on jobStack

May 13th, 2021
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.12
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Controls.impl 2.5
  4. import QtGraphicalEffects 1.0
  5.  
  6.  
  7. Rectangle {
  8.     id: root
  9.     anchors.fill: parent
  10.     color: "black"
  11.     property var unfinishedPrintJob : ([])
  12.  
  13.  
  14.     Button {
  15.         width: 100
  16.         height: 50
  17.         onClicked: {
  18.             getUnfinishedPrintJob();
  19.         }
  20.  
  21.     }
  22.    
  23.     Button {
  24.         y:80
  25.         width: 100
  26.         height: 50
  27.         onClicked: {
  28.             pushUnfinishedPrintJob(3, 999, true);
  29.         }
  30.     }
  31.  
  32.     function getUnfinishedPrintJob () {
  33.         let i;
  34.         for (i=0; i<10; i++) {
  35.             unfinishedPrintJob.push({
  36.                 id: i, //jobName
  37.                 cycle: i*2, //
  38.                 done: false
  39.             });
  40.             //console.log(unfinishedPrintJob[i]);
  41.             //console.log('test');
  42.            
  43.         }
  44.         console.log(JSON.stringify(unfinishedPrintJob) );
  45.     }
  46.        
  47.    
  48.    
  49.     function pushUnfinishedPrintJob (jobId, jobCycle, jobDone) {
  50.         var newJob = {
  51.             id: jobId, //jobName
  52.             cycle: jobCycle, //
  53.             done: jobDone
  54.         }
  55.  
  56.         getUnfinishedPrintJob();
  57.        
  58.         if (unfinishedPrintJob == undefined)
  59.             unfinishedPrintJob = [];
  60.  
  61.  
  62.         //if ( (returnedItem = (order.returned).find(item => item.idPos == idx ))
  63.         var unfinishedIndex;
  64.         if ( unfinishedIndex = unfinishedPrintJob.findIndex(item => item.id == jobId)) {
  65.  
  66.             unfinishedPrintJob.splice(unfinishedIndex, 1, newJob);
  67.  
  68.             // if (unfinishedPrintJob) {
  69.             //  for (var item in unfinishedPrintJob) {
  70.  
  71.             //   }
  72.  
  73.         } else {
  74.             unfinishedPrintJob = [];
  75.             unfinishedPrintJob.push(newJob);
  76.         }
  77.  
  78.         //setUnfinishedPrintJob();
  79.         console.log('' );
  80.         console.log(JSON.stringify(unfinishedPrintJob) );
  81.         console.log('------------------' );
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement