1 # BiaWeb Website content manager (c) 2010 V.Harishankar
6 import site_configuration_dialog
as scd
7 import category_dialog
as catd
11 class MainWindow (PyQt4
.QtGui
.QMainWindow
, ui_main_window
.Ui_MainWindow
):
13 PyQt4
.QtGui
.QMainWindow
.__init
__ (self
)
15 self
.current_db
= None
18 def onCategoryAdd (self
):
19 # if there is no database
20 if self
.current_db
== None:
21 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Error",
22 "Cannot add category. You need to create or open a website first.")
24 # show the category add dialog
25 dlg
= catd
.CategoryDialog (self
)
26 # if OK button is pressed
27 if dlg
.exec_ () == PyQt4
.QtGui
.QDialog
.Accepted
:
28 cat_name
= str (dlg
.category_name
.text ()).strip ()
29 cat_desc
= str (dlg
.category_desc
.text ()).strip ()
30 cat_stub
= str (dlg
.category_stub
.text ()).strip ()
31 ret
= biaweb_db
.create_category (self
.current_db
, cat_name
, cat_desc
, cat_stub
)
33 PyQt4
.QtGui
.QMessageBox
.information (self
, "Success", "Category successfully created")
35 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Error", "SQLite 3 error in creating category")
37 # file new menu is clicked
39 # show the site configuration dialog to get the new site details
40 dlg
= scd
.SiteConfigDialog (self
)
41 # if OK button is pressed
42 if dlg
.exec_ () == PyQt4
.QtGui
.QDialog
.Accepted
:
43 site_title
= str (dlg
.site_title
.text ()).strip ()
44 site_url
= str (dlg
.site_url
.text ()).strip ()
45 keywords
= str (dlg
.keywords
.text ()).strip ()
46 destination
= str (dlg
.destination
.text ()).strip ()
47 description
= str (dlg
.description
.toPlainText ()).strip ()
48 num_rss
= dlg
.num_rss_items
.value ()
49 copyright
= str (dlg
.copyright
.text ()).strip ()
51 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
, "Save site database to")
54 self
.current_db
= str (savefilename
)
55 self
.setWindowTitle ("BiaWeb - " + self
.current_db
)
56 flag
= biaweb_db
.create_db (self
.current_db
, site_title
, site_url
, keywords
, description
,
57 copyright
, num_rss
, destination
)
59 PyQt4
.QtGui
.QMessageBox
.information (self
, "Success",
60 "New site db successfully created")
62 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Error", "System or SQLite 3 error in creating database")
64 # file quit is clicked
65 def onFileQuit (self
):