diff --git a/libs/latex_manager.py b/libs/latex_manager.py index 409cd2f..93ebbb2 100644 --- a/libs/latex_manager.py +++ b/libs/latex_manager.py @@ -75,10 +75,10 @@ class latex_manager(): # TODO: Latex code to compile the songbook # Document class - buf += "\\documentclass[10pt,a5paper,twoside]{book}\n" + buf += "\\documentclass[10pt," + opt["paper_size"] + ",twoside]{book}\n" # Packages - buf += "\\usepackage[a5paper,chordbk]{songbook}\n" + buf += "\\usepackage[" + opt["paper_size"] + "paper, " + opt["type"] + "]{songbook}\n" buf += "\\usepackage[utf8x]{inputenc}\n" buf += "\\usepackage{makeidx}\n" buf += "\n\n" @@ -163,7 +163,7 @@ class latex_manager(): p.wait() # Converto in PS - p = subprocess.Popen("dvips -t a5 canzoniere.dvi -q -o", shell=True, cwd = tmpdir, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + p = subprocess.Popen("dvips -t " + opt["paper_size"] + " canzoniere.dvi -q -o", shell=True, cwd = tmpdir, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) p.wait() # Converto in PDF diff --git a/songbook-editor.py b/songbook-editor.py index a457a8f..3823559 100755 --- a/songbook-editor.py +++ b/songbook-editor.py @@ -55,6 +55,7 @@ class interface(QtGui.QMainWindow): # Menu Canzoniere self.connect(self.ui.actionEsporta_in_LaTeX, QtCore.SIGNAL("activated()"), self.export_songbook) self.connect(self.ui.actionOpzioni_LaTeX, QtCore.SIGNAL("activated()"), self.options) + self.connect(self.ui.actionOrdina_Canzoni, QtCore.SIGNAL("activated()"), self.sort_list) # Functions to manage events @@ -63,6 +64,18 @@ class interface(QtGui.QMainWindow): s = song("") self.set_active_song(s) + def compare_songs(self, song_1, song_2): + if(song_1.title > song_2.title): + return 1 + elif(song_1.title < song_2.title): + return -1 + else: + return 0 + + def sort_list(self): + self.song_db.sort(self.compare_songs) + self.list_update() + # Delete the selected song from the list AND from the song_db def delete_item_from_list(self): song = self.get_active_song() @@ -338,7 +351,8 @@ class option_interface(QtGui.QWidget): self.ui.setupUi(self) # Options dictionary - self.paper_size_dic = {"A4":1, "A5":2} + self.paper_size_dic = {0:"a4", 1:"a5"} + self.type_dic = {0:"chordbk", 1:"wordbk", 2:"overhead"} QtCore.QObject.connect(self.ui.buttonBox, QtCore.SIGNAL("accepted()"), self.ok) @@ -349,18 +363,10 @@ class option_interface(QtGui.QWidget): def ok(self): # Set paper size - if(self.ui.paper_size.currentIndex() == 1): - widget.opt["paper_size"] = "A4" - elif(self.ui.paper_size.currentIndex() == 2): - widget.opt["paper_size"] = "A5" + widget.opt["paper_size"] = self.paper_size_dic[self.ui.paper_size.currentIndex()] # Set songbook type - if(self.ui.type.currentIndex() == 1): - widget.opt["type"] = "tc" - elif(self.ui.type.currentIndex() == 2): - widget.opt["type"] = "c" - elif(self.ui.type.currentIndex() == 3): - widget.opt["type"] == "s" + widget.opt["type"] = self.type_dic[self.ui.type.currentIndex()] # Set songbook title widget.opt["title"] = unicode(self.ui.title.text()) diff --git a/ui/interface.py b/ui/interface.py index 8825455..cdd2778 100644 --- a/ui/interface.py +++ b/ui/interface.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'interface.ui' # -# Created: Sat Jun 20 18:49:32 2009 +# Created: Sat Jun 20 19:06:39 2009 # by: PyQt4 UI code generator 4.4.4 # # WARNING! All changes made in this file will be lost! @@ -211,6 +211,8 @@ class Ui_MainWindow(object): self.actionEsporta_in_DVI.setObjectName("actionEsporta_in_DVI") self.actionEsporta_in_PDF = QtGui.QAction(MainWindow) self.actionEsporta_in_PDF.setObjectName("actionEsporta_in_PDF") + self.actionOrdina_Canzoni = QtGui.QAction(MainWindow) + self.actionOrdina_Canzoni.setObjectName("actionOrdina_Canzoni") self.menuFile.addAction(self.actionApri) self.menuFile.addAction(self.actionSalva) self.menuFile.addSeparator() @@ -219,6 +221,7 @@ class Ui_MainWindow(object): self.menuCanzoniere.addAction(self.actionOpzioni_LaTeX) self.menuCanzoniere.addAction(self.actionEsporta_in_DVI) self.menuCanzoniere.addAction(self.actionEsporta_in_PDF) + self.menuCanzoniere.addAction(self.actionOrdina_Canzoni) self.menuCanzone.addAction(self.actionSalva_canzone) self.menuCanzone.addAction(self.actionImporta_canzone) self.menubar.addAction(self.menuFile.menuAction()) @@ -263,4 +266,5 @@ class Ui_MainWindow(object): self.actionOpzioni_LaTeX.setText(QtGui.QApplication.translate("MainWindow", "Opzioni LaTeX", None, QtGui.QApplication.UnicodeUTF8)) self.actionEsporta_in_DVI.setText(QtGui.QApplication.translate("MainWindow", "Esporta in DVI", None, QtGui.QApplication.UnicodeUTF8)) self.actionEsporta_in_PDF.setText(QtGui.QApplication.translate("MainWindow", "Esporta in PDF", None, QtGui.QApplication.UnicodeUTF8)) + self.actionOrdina_Canzoni.setText(QtGui.QApplication.translate("MainWindow", "Ordina Canzoni", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/ui/interface.ui b/ui/interface.ui index 8fe0a64..57dd46b 100644 --- a/ui/interface.ui +++ b/ui/interface.ui @@ -302,6 +302,7 @@ p, li { white-space: pre-wrap; } <addaction name="actionOpzioni_LaTeX"/> <addaction name="actionEsporta_in_DVI"/> <addaction name="actionEsporta_in_PDF"/> + <addaction name="actionOrdina_Canzoni"/> </widget> <widget class="QMenu" name="menuCanzone"> <property name="title"> @@ -377,6 +378,11 @@ p, li { white-space: pre-wrap; } <string>Esporta in PDF</string> </property> </action> + <action name="actionOrdina_Canzoni"> + <property name="text"> + <string>Ordina Canzoni</string> + </property> + </action> </widget> <resources/> <connections>