Example #1
0
    def save(self):
        if self.item == None: return

        # Save date and time in the task
        d = self.ui.dateTime.date()
        t = self.ui.dateTime.time()

        self.item.task.date = datetime(d.year(), d.month(), d.day(), t.hour(),
                                       t.minute())

        # Save text in the task
        self.item.task.text = unicode(self.ui.task.text())

        # Save tags.
        tags = [s.strip() for s in unicode(self.ui.tags.text()).split(',')]
        # For each tag, see if it is in the DB. If it is not, create it. If you had
        # a million tags, this would be very very wrong code
        self.item.task.tags = []
        for tag in tags:
            dbTag = todo.Tag.get_by(name=tag)
            if dbTag is None:  # Tag is new, create it
                print "Creating tag: ", tag
                self.item.task.tags.append(todo.Tag(name=tag))
            else:
                self.item.task.tags.append(dbTag)

        # Display the data in the item
        self.item.setText(0, self.item.task.text)
        self.item.setText(1, str(self.item.task.date))
        self.item.setText(2, u','.join(t.name for t in self.item.task.tags))

        todo.saveData()
Example #2
0
 def on_actionDelete_Task_triggered(self,checked=None):
     if checked is None: return
     # First see what task is "current".
     item=self.ui.list.currentItem()
     
     if not item: # None selected, so we don't know what to delete!
         return
     # Actually delete the task
     item.task.delete()
     todo.saveData()
     
     # And remove the item. I think that's not pretty. Is it the only way?
     self.ui.list.takeTopLevelItem(self.ui.list.indexOfTopLevelItem(item))
Example #3
0
 def on_actionDelete_Task_triggered(self,checked=None):
     if checked is None: return
     # First see what task is "current".
     item=self.ui.list.currentItem()
     
     if not item: # None selected, so we don't know what to delete!
         return
     # Actually delete the task
     item.task.delete()
     todo.saveData()
     
     # And remove the item. I think that's not pretty. Is it the only way?
     self.ui.list.takeTopLevelItem(self.ui.list.indexOfTopLevelItem(item))
Example #4
0
File: cpu.py Project: lightvfx/LYPA
def main():
    # Init the database before doing anything else
    todo.initDB()
    for task in todo.Task.query().all():
        #print task.done
        if task.done == 0:
            task.done = 1
            todo.saveData()
            print "rendering: " + task.text
            print "finished"
            
        else :
            print "waiting ...... "
    t = Timer(5.0,main)
    t.start()
Example #5
0
File: cpu.py Project: lightvfx/LYPA
def main():
    # Init the database before doing anything else
    todo.initDB()
    for task in todo.Task.query().all():
        #print task.done
        if task.done == 0:
            task.done = 1
            todo.saveData()
            print "rendering: " + task.text
            print "finished"

        else:
            print "waiting ...... "
    t = Timer(5.0, main)
    t.start()
Example #6
0
 def on_actionNew_Task_triggered(self,checked=None):
     if checked is None: return
     # Create a dummy task
     task=todo.Task(text="New Task")
     
     # Create an item reflecting the task
     item=QtGui.QTreeWidgetItem([task.text,str(task.date),""])
     item.setCheckState(0,QtCore.Qt.Unchecked)
     item.task=task
     
     # Put the item in the task list
     self.ui.list.addTopLevelItem(item)
     self.ui.list.setCurrentItem(item)
     # Save it in the DB
     todo.saveData()
     # Open it with the editor
     self.ui.editor.edit(item)
Example #7
0
    def on_actionNew_Task_triggered(self, checked=None):
        if checked is None: return
        # Create a dummy task
        task = todo.Task(text="New Task")

        # Create an item reflecting the task
        item = QtGui.QTreeWidgetItem([task.text, str(task.date), ""])
        item.setCheckState(0, QtCore.Qt.Unchecked)
        item.task = task

        # Put the item in the task list
        self.ui.list.addTopLevelItem(item)
        self.ui.list.setCurrentItem(item)
        # Save it in the DB
        todo.saveData()
        # Open it with the editor
        self.ui.editor.edit(item)
Example #8
0
    def save(self):
        if self.item==None: return
        
        # Save date and time in the task
        d=self.ui.dateTime.date()
        t=self.ui.dateTime.time()
        
        self.item.task.date=datetime(
            d.year(),
            d.month(),
            d.day(),
            t.hour(),
            t.minute()
        )
        
        # Save text in the task
        self.item.task.text=unicode(self.ui.task.text())

        # Save tags.
        tags=[s.strip() for s in unicode(self.ui.tags.text()).split(',')]
        # For each tag, see if it is in the DB. If it is not, create it. If you had 
        # a million tags, this would be very very wrong code
        self.item.task.tags=[]
        for tag in tags:
            dbTag=todo.Tag.get_by(name=tag)
            if dbTag is None: # Tag is new, create it
                print "Creating tag: ",tag
                self.item.task.tags.append(todo.Tag(name=tag))
            else:
                self.item.task.tags.append(dbTag)
                
        # Display the data in the item
        self.item.setText(0,self.item.task.text)
        self.item.setText(1,str(self.item.task.date))
        self.item.setText(2,u','.join(t.name for t in self.item.task.tags))

        todo.saveData()
        
Example #9
0
 def on_list_itemChanged(self,item,column):
     if item.checkState(0):
         item.task.done=True
     else:
         item.task.done=False
     todo.saveData()
Example #10
0
 def on_list_itemChanged(self,item,column):
     if item.checkState(0):
         item.task.done=True
     else:
         item.task.done=False
     todo.saveData()