This commit is contained in:
Ken Roberts 2014-10-21 13:05:35 -07:00
parent 598f94f5c1
commit a8cebffec0
4 changed files with 96 additions and 29 deletions

View File

@ -317,3 +317,50 @@ PJLINK_DEFAULT_SOURCES = {'1': translate('OpenLP.DB', 'RGB'),
'3': translate('OpenLP.DB', 'Digital'),
'4': translate('OpenLP.DB', 'Storage'),
'5': translate('OpenLP.DB', 'Network')}
PJLINK_DEFAULT_CODES = {'11': translate('OpenLP.DB', 'RGB 1'),
'12': translate('OpenLP.DB', 'RGB 2'),
'13': translate('OpenLP.DB', 'RGB 3'),
'14': translate('OpenLP.DB', 'RGB 4'),
'15': translate('OpenLP.DB', 'RGB 5'),
'16': translate('OpenLP.DB', 'RGB 6'),
'17': translate('OpenLP.DB', 'RGB 7'),
'18': translate('OpenLP.DB', 'RGB 8'),
'19': translate('OpenLP.DB', 'RGB 9'),
'21': translate('OpenLP.DB', 'Video 1'),
'22': translate('OpenLP.DB', 'Video 2'),
'23': translate('OpenLP.DB', 'Video 3'),
'24': translate('OpenLP.DB', 'Video 4'),
'25': translate('OpenLP.DB', 'Video 5'),
'26': translate('OpenLP.DB', 'Video 6'),
'27': translate('OpenLP.DB', 'Video 7'),
'28': translate('OpenLP.DB', 'Video 8'),
'29': translate('OpenLP.DB', 'Video 9'),
'31': translate('OpenLP.DB', 'Digital 1'),
'32': translate('OpenLP.DB', 'Digital 2'),
'33': translate('OpenLP.DB', 'Digital 3'),
'34': translate('OpenLP.DB', 'Digital 4'),
'35': translate('OpenLP.DB', 'Digital 5'),
'36': translate('OpenLP.DB', 'Digital 6'),
'37': translate('OpenLP.DB', 'Digital 7'),
'38': translate('OpenLP.DB', 'Digital 8'),
'39': translate('OpenLP.DB', 'Digital 9'),
'41': translate('OpenLP.DB', 'Storage 1'),
'42': translate('OpenLP.DB', 'Storage 2'),
'43': translate('OpenLP.DB', 'Storage 3'),
'44': translate('OpenLP.DB', 'Storage 4'),
'45': translate('OpenLP.DB', 'Storage 5'),
'46': translate('OpenLP.DB', 'Storage 6'),
'47': translate('OpenLP.DB', 'Storage 7'),
'48': translate('OpenLP.DB', 'Storage 8'),
'49': translate('OpenLP.DB', 'Storage 9'),
'51': translate('OpenLP.DB', 'Network 1'),
'52': translate('OpenLP.DB', 'Network 2'),
'53': translate('OpenLP.DB', 'Network 3'),
'54': translate('OpenLP.DB', 'Network 4'),
'55': translate('OpenLP.DB', 'Network 5'),
'56': translate('OpenLP.DB', 'Network 6'),
'57': translate('OpenLP.DB', 'Network 7'),
'58': translate('OpenLP.DB', 'Network 8'),
'59': translate('OpenLP.DB', 'Network 9')
}

View File

@ -52,7 +52,7 @@ from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy.orm import backref, relationship
from openlp.core.lib.db import Manager, init_db, init_url
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_SOURCES
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_SOURCES, PJLINK_DEFAULT_CODES
metadata = MetaData()
Base = declarative_base(metadata)
@ -178,6 +178,22 @@ class Projector(CommonBase, Base):
sources = Column(String(128))
class ProjectorSource(CommonBase, Base):
"""
Projector local source table
This table allows mapping specific projector source input to a local
connection; i.e., '11': 'DVD Player'
Projector Source:
projector_id: Foreign_key(Column(Projector.id))
code: Column(String(3)) # PJLink source code
text: Column(String(20)) # Text to display
"""
code = Column(String(3))
text = Column(String(20))
projector_id = Integer(ForeignKey('projector.id'))
class ProjectorDB(Manager):
"""
Class to access the projector database.
@ -328,36 +344,40 @@ class ProjectorDB(Manager):
log.error('delete_by_id() Entry id="%s" not deleted for some reason' % projector.id)
return deleted
def get_source_list(self, make, model, sources):
def get_source_list(self, projector):
"""
Retrieves the source inputs pjlink code-to-text if available based on
manufacturer and model.
If not available, then returns the PJLink code to default text.
:param make: Manufacturer name as retrieved from projector
:param model: Manufacturer model as retrieved from projector
:param sources: List of available sources (from projector)
:param projector: Projector instance
:returns: dict
key: (str) PJLink code for source
value: (str) From Sources table or default PJLink strings
value: (str) From ProjectorSource, Sources tables or PJLink default code list
"""
source_dict = {}
model_list = self.get_all_objects(Model, Model.name == model)
# Get manufacturer-defined source text
model_list = self.get_all_objects(Model, Model.name == projector.model)
if model_list is None or len(model_list) < 1:
# No entry for model, so see if there's a default entry
default_list = self.get_object_filtered(Manufacturer, Manufacturer.name == make)
default_list = self.get_object_filtered(Manufacturer, Manufacturer.name == projector.manufacturer)
if default_list is None or len(default_list) < 1:
# No entry for manufacturer, so can't check for default text
log.debug('Using default PJLink text for input select')
for source in sources:
log.debug('source = "%s"' % source)
source_dict[source] = '%s %s' % (PJLINK_DEFAULT_SOURCES[source[0]], source[1])
model_list = {}
else:
# We have a manufacturer entry, see if there's a default
# TODO: Finish this section once edit source input is done
pass
else:
# There's at least one model entry, see if there's more than one manufacturer
# TODO: Finish this section once edit source input text is done
pass
model_list = default_list.models['DEFAULT']
# Get user-defined source text
local_list = self.get_all_objects(ProjectorSource, ProjectorSource.projector_id == projector.dbid)
if local_list is None or len(local_list) < 1:
local_list = {}
source_dict = {}
for source in projector.source_available:
if source in local_list:
# User defined source text
source_dict[source] = local_list[source]
elif source in model_list:
# Default manufacturer defined source text
source_dict[source] = model_list[source]
else:
# Default PJLink source text
source_dict[source] = PJLINK_DEFAULT_CODES[source]
return source_dict

View File

@ -114,13 +114,11 @@ class Ui_ProjectorEditForm(object):
self.dialog_layout.addWidget(self.button_box, 8, 0, 1, 2)
def retranslateUi(self, edit_projector_dialog):
if self.projector.port is None:
if self.new_projector:
title = translate('OpenLP.ProjectorEditForm', 'Add New Projector')
self.projector.port = PJLINK_PORT
self.new_projecor = True
else:
title = translate('OpenLP.ProjectorEditForm', 'Edit Projector')
self.new_projector = False
edit_projector_dialog.setWindowTitle(title)
self.ip_label.setText(translate('OpenLP.ProjetorEditForm', 'IP Address'))
self.ip_text.setText(self.projector.ip)
@ -159,9 +157,13 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm):
self.button_box.helpRequested.connect(self.help_me)
self.button_box.rejected.connect(self.cancel_me)
def exec_(self, projector=Projector()):
self.projector = projector
self.new_projector = False
def exec_(self, projector=None):
if projector is None:
self.projector = Projector()
self.new_projector = True
else:
self.projector = projector
self.new_projector = False
self.retranslateUi(self)
reply = QDialog.exec_(self)
self.projector = None

View File

@ -223,9 +223,7 @@ class SourceSelectTabs(QDialog):
:param projector: Projector instance to build source list from
"""
self.projector = projector
self.source_text = self.projectordb.get_source_list(projector.manufacturer,
projector.model,
projector.source_available)
self.source_text = self.projectordb.get_source_list(projector=projector)
self.source_group = source_group(projector.source_available, self.source_text)
# self.source_group = {'4': {'41': 'Storage 1'}, '5': {"51": 'Network 1'}}
self.button_group = QButtonGroup()