예제 #1
0
파일: editor.py 프로젝트: Yaruki00/Todo
 def save(self):
     if self.item == None:
         return
     d = self.dateTimeEdit.date()
     t = self.dateTimeEdit.time()
     self.item.task.date = datetime(
         d.year(),
         d.month(),
         d.day(),
         t.hour(),
         t.minute()
     )
     self.item.task.text = unicode(self.taskLineEdit.text())
     if self.doneCheck.checkState() == QtCore.Qt.Checked:
         self.item.task.done = True
     else:
         self.item.task.done = False
     if self.parentCheck.checkState() == QtCore.Qt.Checked:
         self.item.task.parent = self.selectParent.currentText().__str__()
     tags = [s.strip() for s in unicode(self.tagLineEdit.text()).split(',')]
     self.item.task.tags = []
     for tag in tags:
         dbTag = todoDB.Tag.get_by(name = tag)
         if dbTag is None:
             self.item.task.tags.append(todoDB.Tag(name=tag))
         else:
             self.item.task.tags.append(dbTag)
     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))
     self.item.setCheckState(0, self.doneCheck.checkState())
     todoDB.saveData()
     self.hide()
     self.parent.loadData()
예제 #2
0
 def save(self):
     if self.item == None:
         return
     d = self.dateTimeEdit.date()
     t = self.dateTimeEdit.time()
     self.item.task.date = datetime(d.year(), d.month(), d.day(), t.hour(),
                                    t.minute())
     self.item.task.text = unicode(self.taskLineEdit.text())
     if self.doneCheck.checkState() == QtCore.Qt.Checked:
         self.item.task.done = True
     else:
         self.item.task.done = False
     if self.parentCheck.checkState() == QtCore.Qt.Checked:
         self.item.task.parent = self.selectParent.currentText().__str__()
     tags = [s.strip() for s in unicode(self.tagLineEdit.text()).split(',')]
     self.item.task.tags = []
     for tag in tags:
         dbTag = todoDB.Tag.get_by(name=tag)
         if dbTag is None:
             self.item.task.tags.append(todoDB.Tag(name=tag))
         else:
             self.item.task.tags.append(dbTag)
     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))
     self.item.setCheckState(0, self.doneCheck.checkState())
     todoDB.saveData()
     self.hide()
     self.parent.loadData()
예제 #3
0
파일: todo.py 프로젝트: Yaruki00/Todo
 def on_treeWidget_itemChanged(self, item, column):
     # finished?
     if item.checkState(0):
         item.task.done = True
     else:
         item.task.done = False
     todoDB.saveData()
     # fix width
     for column in range(0, self.treeWidget.columnCount()):
         self.treeWidget.resizeColumnToContents(column)
예제 #4
0
 def on_treeWidget_itemChanged(self, item, column):
     # finished?
     if item.checkState(0):
         item.task.done = True
     else:
         item.task.done = False
     todoDB.saveData()
     # fix width
     for column in range(0, self.treeWidget.columnCount()):
         self.treeWidget.resizeColumnToContents(column)
예제 #5
0
파일: todo.py 프로젝트: Yaruki00/Todo
 def new(self):
     # collect top items
     topItems = []
     for i in range(0, self.treeWidget.topLevelItemCount()):
         topItems.append(self.treeWidget.topLevelItem(i))
     # create new task
     task = todoDB.Task(text=u"New Task")
     item = QtGui.QTreeWidgetItem([task.text, str(task.date), ""])
     item.setCheckState(0, QtCore.Qt.Unchecked)
     item.task = task
     # add new item to treeWidget
     self.treeWidget.addTopLevelItem(item)
     self.treeWidget.setCurrentItem(item)
     todoDB.saveData()
     self.editor.edit(item, topItems, True)
예제 #6
0
 def new(self):
     # collect top items
     topItems = []
     for i in range(0, self.treeWidget.topLevelItemCount()):
         topItems.append(self.treeWidget.topLevelItem(i))
     # create new task
     task = todoDB.Task(text=u"New Task")
     item = QtGui.QTreeWidgetItem([task.text, str(task.date), ""])
     item.setCheckState(0, QtCore.Qt.Unchecked)
     item.task = task
     # add new item to treeWidget
     self.treeWidget.addTopLevelItem(item)
     self.treeWidget.setCurrentItem(item)
     todoDB.saveData()
     self.editor.edit(item, topItems, True)
예제 #7
0
 def delete(self):
     selectedItem = self.treeWidget.currentItem()
     if not selectedItem:
         return
     reply = QtGui.QMessageBox.question(
         self, 'Confirmation', "Are you sure to delete?",
         QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
     if reply == QtGui.QMessageBox.Yes:
         # delete all children
         for i in range(0, selectedItem.childCount()):
             selectedItem.child(i).task.delete()
         # delete itself
         selectedItem.task.delete()
         todoDB.saveData()
         # update UI
         if selectedItem.parent():
             selectedItem.parent().removeChild(selectedItem)
         else:
             self.treeWidget.takeTopLevelItem(
                 self.treeWidget.indexOfTopLevelItem(selectedItem))
예제 #8
0
파일: todo.py 프로젝트: Yaruki00/Todo
 def delete(self):
     selectedItem = self.treeWidget.currentItem()
     if not selectedItem:
         return
     reply = QtGui.QMessageBox.question(self,
                                'Confirmation',
                                "Are you sure to delete?",
                                QtGui.QMessageBox.Yes |
                                QtGui.QMessageBox.No,
                                QtGui.QMessageBox.No)
     if reply == QtGui.QMessageBox.Yes:
         # delete all children
         for i in range(0, selectedItem.childCount()):
             selectedItem.child(i).task.delete()
         # delete itself
         selectedItem.task.delete()
         todoDB.saveData()
         # update UI
         if selectedItem.parent():
             selectedItem.parent().removeChild(selectedItem)
         else:
             self.treeWidget.takeTopLevelItem(self.treeWidget.indexOfTopLevelItem(selectedItem))
예제 #9
0
파일: editor.py 프로젝트: Yaruki00/Todo
 def cancel(self):
     if self.new:
         self.item.task.delete()
         todoDB.saveData()
     self.hide()
     self.parent.loadData()
예제 #10
0
 def cancel(self):
     if self.new:
         self.item.task.delete()
         todoDB.saveData()
     self.hide()
     self.parent.loadData()