import ui_main_window
import site_configuration_dialog as scd
import category_dialog as catd
+import article_dialog as artd
import biaweb_db
import sys
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 add article is triggered
+ def onArticleAdd (self):
+ if self.current_db == None:
+ PyQt4.QtGui.QMessageBox.critical (self, "Error",
+ "Cannot create article. You need to create or open a website first")
+ else:
+ catid = self.get_selected_item_id (self.categories)
+ # if no category is selected
+ if catid is None:
+ PyQt4.QtGui.QMessageBox.critical (self, "Error", "No category selected for article")
+ return
+ artdlg = artd.ArticleDialog (self)
+ artdlg.exec_ ()
+
+
+ # when edit article is triggered
+ def onArticleEdit (self):
+ pass
+
+ # when delete article is triggered
+ def onArticleDelete (self):
+ pass
+
+ # 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",
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