X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=main_window.py;fp=main_window.py;h=0d6c91a5d96036ed4690a2091e88e624cc3be40a;hp=4d4afa35dd6e95cb04832aeb7e00212fce277856;hb=e14aab0777f4dcc7200894ee75fab329007adb53;hpb=8c9cfa39545fd48c66d4e795a6d2d7faa396c6c9 diff --git a/main_window.py b/main_window.py index 4d4afa3..0d6c91a 100644 --- a/main_window.py +++ b/main_window.py @@ -38,7 +38,19 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow): qrow = PyQt4.QtGui.QTreeWidgetItem ([str(item[0]), str(item[1])]) self.articles.addTopLevelItem (qrow) - # configuration dialog + # when the view is refreshed + def onViewRefresh (self): + if self.current_db is not None: + self.repopulate_categories () + self.repopulate_articles () + + # when item selection is changed in categories tree widget + def onCategorySelectionChanged (self): + if self.current_db is not None: + catid = self.get_selected_item_id (self.categories) + self.repopulate_articles (catid) + + # when configuration menu is activated def onConfiguration (self): if self.current_db == None: PyQt4.QtGui.QMessageBox.critical (self, "Error", @@ -126,6 +138,32 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow): PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in updating category") + # category delete action + def onCategoryDelete (self): + # if there is no database + if self.current_db == None: + PyQt4.QtGui.QMessageBox.critical (self, "Error", + "Cannot edit category. You need to create or open a website first") + else: + # get the selected category + catid = self.get_selected_item_id (self.categories) + if catid is None: + PyQt4.QtGui.QMessageBox.critical (self, "Error", "No category selected") + # category is selected + else: + # get confirmation first + flag = PyQt4.QtGui.QMessageBox.question (self, "Confirm", + "This will delete the category and all associated articles. Are you sure you wish to continue?", + PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No) + # if confirmed + if flag == PyQt4.QtGui.QMessageBox.Yes: + ret = biaweb_db.remove_category (self.current_db, catid) + if ret == False: + PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in deleting category") + else: + self.repopulate_categories () + self.repopulate_articles () + # category add action def onCategoryAdd (self): # if there is no database