Beispiel #1
0
    def editCategory(self):
        selectedCategory = self.ui.treeWidget.currentItem()

        if (selectedCategory != None):

            #just edit categories
            if (not isinstance(selectedCategory, TICategoryWidget)):
                return

            selectedCategoryText = selectedCategory.categoryText()

            categoryInput = TICategoryDialog(self)
            categoryInput.setCategoryText(selectedCategoryText)
            categoryInput.exec_()

            if (categoryInput.result() == TICategoryDialog.Accepted):
                #this returns QString so str() it
                selectedCategoryId = selectedCategory.categoryId()
                updatedCategoryText = str(categoryInput.categoryText())

                dbHandler = self.dbHandler
                dbHandler.editCategory(selectedCategoryId, updatedCategoryText)

                selectedCategory.setCategoryText(updatedCategoryText)
                self.tasklistModification(True)
Beispiel #2
0
    def addCategory(self):
        categoryDialog = TICategoryDialog(self)
        categoryDialog.exec_()

        if (categoryDialog.result() == TICategoryDialog.Accepted):
            categoryText = str(categoryDialog.categoryText())

            dbHandler = self.dbHandler
            categoryId = dbHandler.addCategory(categoryText)

            categoryWidget = TICategoryWidget(categoryText, categoryId)

            self.ui.treeWidget.addTopLevelItem(categoryWidget)
            self.ui.treeWidget.expandItem(categoryWidget)
            self.tasklistModification(True)

            self.ui.treeWidget.setCurrentItem(categoryWidget)