# BiaWeb Website content manager (c) 2010 V.Harishankar
-# Category dialog class
+# Article dialog class
import PyQt4
import ui_article_dialog
+import highlighter
class ArticleDialog (PyQt4.QtGui.QDialog, ui_article_dialog.Ui_ArticleDialog):
def __init__ (self, parent):
PyQt4.QtGui.QDialog.__init__ (self, parent)
self.setupUi (self)
+ # set the code highlighter to the document
+ self.hltext = highlighter.SimpleHtmlHighlighter (self.content.document ())
# when rejected, confirm first
def reject (self):
</property>
</widget>
</item>
- <item row="5" column="0" colspan="22">
- <widget class="QPlainTextEdit" name="content">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>210</height>
- </size>
- </property>
- <property name="verticalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOn</enum>
- </property>
- </widget>
- </item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Center para</p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Shortcut: Ctrl+C</span></p></body></html></string>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Shortcut: Ctrl+O</span></p></body></html></string>
</property>
<property name="text">
<string/>
<normaloff>:/bia/resources/center.gif</normaloff>:/bia/resources/center.gif</iconset>
</property>
<property name="shortcut">
- <string>Ctrl+C</string>
+ <string>Ctrl+O</string>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
+ <item row="5" column="0" colspan="22">
+ <widget class="QPlainTextEdit" name="content">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>210</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ </font>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOn</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<tabstops>
<slot>onJustify()</slot>
<hints>
<hint type="sourcelabel">
- <x>302</x>
- <y>211</y>
+ <x>332</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>98</x>
<slot>onBullet()</slot>
<hints>
<hint type="sourcelabel">
- <x>355</x>
- <y>199</y>
+ <x>386</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>336</x>
<slot>onNumber()</slot>
<hints>
<hint type="sourcelabel">
- <x>387</x>
- <y>195</y>
+ <x>422</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>372</x>
<slot>onBQuote()</slot>
<hints>
<hint type="sourcelabel">
- <x>423</x>
- <y>203</y>
+ <x>458</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>311</x>
<slot>onCode()</slot>
<hints>
<hint type="sourcelabel">
- <x>457</x>
- <y>203</y>
+ <x>494</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>311</x>
<slot>onTable()</slot>
<hints>
<hint type="sourcelabel">
- <x>492</x>
- <y>203</y>
+ <x>530</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>311</x>
<slot>onHRule()</slot>
<hints>
<hint type="sourcelabel">
- <x>532</x>
- <y>203</y>
+ <x>572</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>311</x>
<slot>onPara()</slot>
<hints>
<hint type="sourcelabel">
- <x>566</x>
- <y>203</y>
+ <x>608</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>311</x>
<slot>onBreak()</slot>
<hints>
<hint type="sourcelabel">
- <x>601</x>
- <y>203</y>
+ <x>644</x>
+ <y>219</y>
</hint>
<hint type="destinationlabel">
<x>311</x>
<slot>onHRule()</slot>
<slot>onPara()</slot>
<slot>onBreak()</slot>
+ <slot>onTextChanged()</slot>
</slots>
</ui>
--- /dev/null
+# BiaWeb Website content manager (c) 2010 V.Harishankar
+# HTML highlighter class
+
+import PyQt4
+
+class SimpleHtmlHighlighter (PyQt4.QtGui.QSyntaxHighlighter):
+ def __init__ (self, document):
+ PyQt4.QtGui.QSyntaxHighlighter.__init__ (self, document)
+
+ def highlightBlock (self, text):
+ # define the character highlight formats
+ charfmt1 = PyQt4.QtGui.QTextCharFormat ()
+ charfmt1.setFontWeight (PyQt4.QtGui.QFont.Bold)
+ charfmt1.setForeground (PyQt4.QtCore.Qt.blue)
+
+ charfmt2 = PyQt4.QtGui.QTextCharFormat ()
+ charfmt2.setForeground (PyQt4.QtCore.Qt.darkGreen)
+
+ # matching regular expressions
+ htmltagexps = [ (PyQt4.QtCore.QRegExp ("<[^<>]+>"), charfmt1),
+ (PyQt4.QtCore.QRegExp ("\"[^\"]+\""), charfmt2)
+ ]
+
+ # run through the list of regular expressions to highlight
+ for htmltagexp, charfmt in htmltagexps:
+ index = htmltagexp.indexIn (text)
+ while index >= 0:
+ length = htmltagexp.matchedLength ()
+ # self.setFormat is actual code highlighting
+ self.setFormat (index, length, charfmt)
+ index = htmltagexp.indexIn (text, index + length)
<rect>
<x>0</x>
<y>0</y>
- <width>633</width>
- <height>458</height>
+ <width>798</width>
+ <height>517</height>
</rect>
</property>
<property name="windowTitle">
<rect>
<x>0</x>
<y>0</y>
- <width>633</width>
+ <width>798</width>
<height>25</height>
</rect>
</property>
</property>
</action>
</widget>
+ <tabstops>
+ <tabstop>categories</tabstop>
+ <tabstop>articles</tabstop>
+ </tabstops>
<resources/>
<connections>
<connection>
# Form implementation generated from reading ui file 'article_dialog.ui'
#
-# Created: Sun Nov 28 13:59:41 2010
+# Created: Sun Nov 28 17:32:45 2010
# by: PyQt4 UI code generator 4.7.4
#
# WARNING! All changes made in this file will be lost!
self.linebreak.setAutoRaise(False)
self.linebreak.setObjectName("linebreak")
self.gridLayout.addWidget(self.linebreak, 4, 21, 1, 1)
- self.content = QtGui.QPlainTextEdit(ArticleDialog)
- self.content.setMinimumSize(QtCore.QSize(0, 210))
- self.content.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
- self.content.setObjectName("content")
- self.gridLayout.addWidget(self.content, 5, 0, 1, 22)
self.label_4 = QtGui.QLabel(ArticleDialog)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 6, 0, 1, 2)
self.blockquote.setAutoRaise(False)
self.blockquote.setObjectName("blockquote")
self.gridLayout.addWidget(self.blockquote, 4, 15, 1, 1)
+ self.content = QtGui.QPlainTextEdit(ArticleDialog)
+ self.content.setMinimumSize(QtCore.QSize(0, 210))
+ font = QtGui.QFont()
+ font.setFamily("Monospace")
+ self.content.setFont(font)
+ self.content.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
+ self.content.setObjectName("content")
+ self.gridLayout.addWidget(self.content, 5, 0, 1, 22)
self.retranslateUi(ArticleDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), ArticleDialog.accept)
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Center para</p>\n"
-"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-style:italic;\">Shortcut: Ctrl+C</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
- self.paracenter.setShortcut(QtGui.QApplication.translate("ArticleDialog", "Ctrl+C", None, QtGui.QApplication.UnicodeUTF8))
+"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-style:italic;\">Shortcut: Ctrl+O</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+ self.paracenter.setShortcut(QtGui.QApplication.translate("ArticleDialog", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8))
self.paraleft.setToolTip(QtGui.QApplication.translate("ArticleDialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
# Form implementation generated from reading ui file 'main_window.ui'
#
-# Created: Sun Nov 28 09:35:09 2010
+# Created: Sun Nov 28 15:30:11 2010
# by: PyQt4 UI code generator 4.7.4
#
# WARNING! All changes made in this file will be lost!
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
- MainWindow.resize(633, 458)
+ MainWindow.resize(798, 517)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtGui.QGridLayout(self.centralwidget)
self.dockWidget_2.setWidget(self.dockWidgetContents_2)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidget_2)
self.menubar = QtGui.QMenuBar(MainWindow)
- self.menubar.setGeometry(QtCore.QRect(0, 0, 633, 25))
+ self.menubar.setGeometry(QtCore.QRect(0, 0, 798, 25))
self.menubar.setObjectName("menubar")
self.menu_About = QtGui.QMenu(self.menubar)
self.menu_About.setObjectName("menu_About")
QtCore.QObject.connect(self.action_EditArticle, QtCore.SIGNAL("triggered()"), MainWindow.onArticleEdit)
QtCore.QObject.connect(self.action_DeleteArticle, QtCore.SIGNAL("triggered()"), MainWindow.onArticleDelete)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
+ MainWindow.setTabOrder(self.categories, self.articles)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "BiaWeb - Static Website Content Manager", None, QtGui.QApplication.UnicodeUTF8))