forked from openlp/openlp
Start fixing the songs plugin
This commit is contained in:
parent
5fbc870c64
commit
a473a4dffc
@ -3,7 +3,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
from textlistdata import TextListData
|
||||
from authorsform import AuthorsForm
|
||||
from topicsform import TopicsForm
|
||||
from songbookform import SongBookForm
|
||||
|
@ -2,7 +2,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -17,10 +17,6 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PyQt4.QtCore import pyqtSignature
|
||||
|
||||
from openlp.core.resources import *
|
||||
from openlp.plugins.songs.lib.classes import *
|
||||
|
||||
from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
|
||||
|
||||
@ -38,17 +34,27 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
self.AuthorListView.setColumnCount(2)
|
||||
self.AuthorListView.setColumnHidden(0, True)
|
||||
self.AuthorListView.setColumnWidth(1, 300)
|
||||
#self.AuthorListView.setHorizontalHeaderLabels(QtCore.QStringList([" ","Author"]))
|
||||
self.AuthorListView.horizontalHeader().setVisible(False)
|
||||
self.AuthorListView.verticalHeader().setVisible(False)
|
||||
self.currentrow = 0
|
||||
self.currentRow = 0
|
||||
self.author = None
|
||||
|
||||
QtCore.QObject.connect(self.DeleteButton,
|
||||
QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
|
||||
QtCore.QObject.connect(self.ClearButton,
|
||||
QtCore.SIGNAL('pressed()'), self.onClearButtonClick)
|
||||
QtCore.QObject.connect(self.AddUpdateButton,
|
||||
QtCore.SIGNAL('pressed()'), self.onAddUpdateButtonClick)
|
||||
QtCore.QObject.connect(self.DisplayEdit,
|
||||
QtCore.SIGNAL('pressed()'), self.onDisplayEditLostFocus)
|
||||
QtCore.QObject.connect(self.AuthorListView,
|
||||
QtCore.SIGNAL('pressed()'), self.onAuthorListViewItemClicked)
|
||||
|
||||
def load_form(self):
|
||||
"""
|
||||
Refresh the screen and rest fields
|
||||
"""
|
||||
self.on_ClearButton_clicked() # tidy up screen
|
||||
self.onClearButtonClick() # tidy up screen
|
||||
authors = self.songmanager.get_authors()
|
||||
self.AuthorListView.clear() # clear the results
|
||||
#self.AuthorListView.setHorizontalHeaderLabels(QtCore.QStringList([" ","Author"]))
|
||||
@ -65,27 +71,24 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
self.AuthorListView.setItem(row_count, 1, display_name)
|
||||
self.AuthorListView.setRowHeight(row_count, 20)
|
||||
row_count = self.AuthorListView.rowCount()
|
||||
if self.currentrow > row_count:
|
||||
if self.currentRow > row_count:
|
||||
# in case we have delete the last row of the table
|
||||
self.currentrow = row_count
|
||||
self.AuthorListView.selectRow(self.currentrow) # set selected row to previous selected row
|
||||
self.currentRow = row_count
|
||||
self.AuthorListView.selectRow(self.currentRow) # set selected row to previous selected row
|
||||
self._validate_form()
|
||||
|
||||
@pyqtSignature("")
|
||||
def on_DeleteButton_clicked(self):
|
||||
def onDeleteButtonClick(self):
|
||||
"""
|
||||
Delete the author is the Author is not attached to any songs
|
||||
"""
|
||||
self.songmanager.delete_author(self.author.id)
|
||||
self.on_ClearButton_clicked()
|
||||
self.onClearButtonClick()
|
||||
self.load_form()
|
||||
|
||||
@pyqtSignature("")
|
||||
def on_DisplayEdit_lostFocus(self):
|
||||
def onDisplayEditLostFocus(self):
|
||||
self._validate_form()
|
||||
|
||||
@pyqtSignature("")
|
||||
def on_AddUpdateButton_clicked(self):
|
||||
def onAddUpdateButtonClick(self):
|
||||
"""
|
||||
Sent New or update details to the database
|
||||
"""
|
||||
@ -95,13 +98,11 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
self.author.first_name = unicode(self.FirstNameEdit.displayText())
|
||||
self.author.last_name = unicode(self.LastNameEdit.displayText())
|
||||
self.songmanager.save_author(self.author)
|
||||
self.on_ClearButton_clicked()
|
||||
self.onClearButtonClick()
|
||||
self.load_form()
|
||||
self._validate_form()
|
||||
|
||||
|
||||
@pyqtSignature("")
|
||||
def on_ClearButton_clicked(self):
|
||||
def onClearButtonClick(self):
|
||||
"""
|
||||
Tidy up screen if clear button pressed
|
||||
"""
|
||||
@ -113,14 +114,13 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
self.author = None
|
||||
self._validate_form()
|
||||
|
||||
@pyqtSignature("QTableWidgetItem*")
|
||||
def on_AuthorListView_itemClicked(self, item):
|
||||
def onAuthorListViewItemClicked(self, item):
|
||||
"""
|
||||
An Author has been selected display it
|
||||
If the author is attached to a Song prevent delete
|
||||
"""
|
||||
self.currentrow = self.AuthorListView.currentRow()
|
||||
id = int(self.AuthorListView.item(self.currentrow, 0).text())
|
||||
self.currentRow = self.AuthorListView.currentRow()
|
||||
id = int(self.AuthorListView.item(self.currentRow, 0).text())
|
||||
self.author = self.songmanager.get_author(id)
|
||||
|
||||
self.DisplayEdit.setText(self.author.display_name)
|
||||
|
@ -108,10 +108,10 @@ class Ui_EditSongDialog(object):
|
||||
self.ThemeSelectionComboItem = QtGui.QComboBox(self.ThemeGroupBox)
|
||||
self.ThemeSelectionComboItem.setObjectName("ThemeSelectionComboItem")
|
||||
self.ThemeLayout.addWidget(self.ThemeSelectionComboItem)
|
||||
self.ThemeAddItem = QtGui.QPushButton(self.ThemeGroupBox)
|
||||
self.ThemeAddItem.setMaximumSize(QtCore.QSize(110, 16777215))
|
||||
self.ThemeAddItem.setObjectName("ThemeAddItem")
|
||||
self.ThemeLayout.addWidget(self.ThemeAddItem)
|
||||
# self.ThemeAddItem = QtGui.QPushButton(self.ThemeGroupBox)
|
||||
# self.ThemeAddItem.setMaximumSize(QtCore.QSize(110, 16777215))
|
||||
# self.ThemeAddItem.setObjectName("ThemeAddItem")
|
||||
# self.ThemeLayout.addWidget(self.ThemeAddItem)
|
||||
self.DetailsLayout.addWidget(self.ThemeGroupBox)
|
||||
self.TopLayout.addWidget(self.TextWidget)
|
||||
self.AdditionalWidget = QtGui.QWidget(self.TopWidget)
|
||||
@ -305,8 +305,7 @@ class Ui_EditSongDialog(object):
|
||||
EditSongDialog.setTabOrder(self.AlternativeEdit, self.VerseOrderEdit)
|
||||
EditSongDialog.setTabOrder(self.VerseOrderEdit, self.CommentsEdit)
|
||||
EditSongDialog.setTabOrder(self.CommentsEdit, self.ThemeSelectionComboItem)
|
||||
EditSongDialog.setTabOrder(self.ThemeSelectionComboItem, self.ThemeAddItem)
|
||||
EditSongDialog.setTabOrder(self.ThemeAddItem, self.AuthorAddtoSongItem)
|
||||
EditSongDialog.setTabOrder(self.ThemeSelectionComboItem, self.AuthorAddtoSongItem)
|
||||
EditSongDialog.setTabOrder(self.AuthorAddtoSongItem, self.AuthorsListView)
|
||||
EditSongDialog.setTabOrder(self.AuthorsListView, self.AuthorRemoveItem)
|
||||
EditSongDialog.setTabOrder(self.AuthorRemoveItem, self.SongbookCombo)
|
||||
@ -330,7 +329,6 @@ class Ui_EditSongDialog(object):
|
||||
self.VerseOrderLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Verse Order:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.CommentsLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Comments:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.ThemeGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Theme", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.ThemeAddItem.setText(QtGui.QApplication.translate("EditSongDialog", "Add a Theme", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.AuthorsGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Authors", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.AuthorAddtoSongItem.setText(QtGui.QApplication.translate("EditSongDialog", "Add to Song", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.AuthorRemoveItem.setText(QtGui.QApplication.translate("EditSongDialog", "Remove", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
@ -3,7 +3,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
|
@ -2,7 +2,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -17,8 +17,6 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
from openlp.core.resources import *
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PyQt4.QtGui import QDialog
|
||||
from PyQt4.QtCore import pyqtSignature
|
||||
@ -35,9 +33,9 @@ class SongBookForm(QDialog, Ui_SongBookDialog):
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.songmanager = songmanager
|
||||
|
||||
|
||||
def load_form(self):
|
||||
A = 1
|
||||
A = 1
|
||||
|
||||
@pyqtSignature("QTableWidgetItem*")
|
||||
def on_BookSongListView_itemClicked(self, item):
|
||||
@ -45,14 +43,14 @@ class SongBookForm(QDialog, Ui_SongBookDialog):
|
||||
Slot documentation goes here.
|
||||
"""
|
||||
print "bslv ic " + str(item)
|
||||
|
||||
|
||||
@pyqtSignature("")
|
||||
def on_DeleteButton_clicked(self):
|
||||
"""
|
||||
Slot documentation goes here.
|
||||
"""
|
||||
print "db c "
|
||||
|
||||
|
||||
@pyqtSignature("")
|
||||
def on_AddUpdateButton_clicked(self):
|
||||
"""
|
||||
|
80
openlp/plugins/songs/forms/textlistdata.py
Normal file
80
openlp/plugins/songs/forms/textlistdata.py
Normal file
@ -0,0 +1,80 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
class TextListData(QtCore.QAbstractListModel):
|
||||
"""
|
||||
An abstract list of strings
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'TextListData')
|
||||
log.info(u'started')
|
||||
|
||||
def __init__(self):
|
||||
QtCore.QAbstractListModel.__init__(self)
|
||||
self.items = [] # will be a list of (database id , title) tuples
|
||||
|
||||
def resetStore(self):
|
||||
#reset list so can be reloaded
|
||||
self.items = []
|
||||
|
||||
def rowCount(self, parent):
|
||||
return len(self.items)
|
||||
|
||||
def insertRow(self, row, id, title):
|
||||
self.beginInsertRows(QtCore.QModelIndex(),row,row)
|
||||
log.debug("insert row %d:%s for id %d" % (row,title, id))
|
||||
self.items.insert(row, (id, title))
|
||||
self.endInsertRows()
|
||||
|
||||
def removeRow(self, row):
|
||||
self.beginRemoveRows(QtCore.QModelIndex(), row,row)
|
||||
self.items.pop(row)
|
||||
self.endRemoveRows()
|
||||
|
||||
def addRow(self, id, title):
|
||||
self.insertRow(len(self.items), id, title)
|
||||
|
||||
def data(self, index, role):
|
||||
row = index.row()
|
||||
if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
|
||||
return QtCore.QVariant()
|
||||
if role == QtCore.Qt.DisplayRole:
|
||||
retval = self.items[row][1]
|
||||
else:
|
||||
retval = QtCore.QVariant()
|
||||
if type(retval) is not type(QtCore.QVariant):
|
||||
return QtCore.QVariant(retval)
|
||||
else:
|
||||
return retval
|
||||
|
||||
def getIdList(self):
|
||||
filelist = [item[0] for item in self.items];
|
||||
return filelist
|
||||
|
||||
def getId(self, index):
|
||||
row = index.row()
|
||||
return self.items[row][0]
|
||||
|
||||
def deleteRow(self, index):
|
||||
row = index.row()
|
||||
self.removeRow(row)
|
@ -2,7 +2,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
from openlp.core.resources import *
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PyQt4.QtGui import QDialog
|
||||
|
@ -227,10 +227,11 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.edit_song_form.exec_()
|
||||
|
||||
def onSongEditClick(self):
|
||||
current_row = self.SongListView.currentRow()
|
||||
id = int(self.SongListView.item(current_row, 0).text())
|
||||
self.edit_song_form.loadSong(id)
|
||||
self.edit_song_form.exec_()
|
||||
indexes = self.SongListView.selectedIndexes()
|
||||
for index in indexes:
|
||||
id = self.SongListData.getId(index)
|
||||
self.edit_song_form.loadSong(id)
|
||||
self.edit_song_form.exec_()
|
||||
|
||||
def onSongDeleteClick(self):
|
||||
indexes = self.SongListView.selectedIndexes()
|
||||
|
Loading…
Reference in New Issue
Block a user