Fix up object copy and get to work.

This commit is contained in:
Tim Bentley 2010-04-24 20:57:29 +01:00
parent d7e060c503
commit b0763714c8
3 changed files with 15 additions and 108 deletions

View File

@ -24,6 +24,7 @@
###############################################################################
import logging
import copy
log = logging.getLogger(__name__)
@ -36,6 +37,7 @@ class ScreenList(object):
def __init__(self):
self.preview = None
self.current = None
self.override = None
self.screen_list = []
self.display_count = 0
#actual display number
@ -59,13 +61,14 @@ class ScreenList(object):
"""
Set up the current screen dimensions
"""
log.debug(u'set_override_display %s', number, )
if number + 1 > self.display_count:
self.current = self.screen_list[0]
self.current_display = 0
else:
self.current = self.screen_list[number]
self.override = self.current
self.preview = self.current
self.override = copy.deepcopy(self.current)
self.preview = copy.deepcopy(self.current)
self.current_display = number
if self.display_count == 1:
self.preview = self.screen_list[0]
@ -75,12 +78,14 @@ class ScreenList(object):
replace the current size with the override values
user wants to have their own screen attributes
"""
self.current = self.override
self.preview = self.current
log.debug(u'set_override_display')
self.current = copy.deepcopy(self.override)
self.preview = copy.deepcopy(self.current)
def reset_current(self):
def reset_current_display(self):
"""
replace the current values with the correct values
user wants to use the correct screen attributes
"""
log.debug(u'reset_current_display')
self.set_current_display(self.current_display)

View File

@ -102,6 +102,11 @@ class DisplayPlugin(Plugin):
self.DisplayMenu.menuAction().setVisible(False)
def toggleDisplayState(self):
log.info(u'toggleDisplayState')
if self.DisplayStatus.isChecked():
self.screens.set_override_display()
else:
self.screens.reset_current_display()
Receiver.send_message(u'config_screen_changed')
def onDisplayOverride(self):

View File

@ -42,30 +42,6 @@ class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog):
self.item_id = None
QtGui.QDialog.__init__(self, None)
self.setupUi(self)
# QtCore.QObject.connect(self.DisplayButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onDisplayClicked)
# QtCore.QObject.connect(self.DisplayCloseButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onDisplayCloseClicked)
# QtCore.QObject.connect(self.AlertTextEdit,
# QtCore.SIGNAL(u'textChanged(const QString&)'),
# self.onTextChanged)
# QtCore.QObject.connect(self.NewButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onNewClick)
# QtCore.QObject.connect(self.DeleteButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onDeleteClick)
# QtCore.QObject.connect(self.SaveButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onSaveClick)
# QtCore.QObject.connect(self.AlertListWidget,
# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
# self.onDoubleClick)
# QtCore.QObject.connect(self.AlertListWidget,
# QtCore.SIGNAL(u'clicked(QModelIndex)'),
# self.onSingleClick)
def initialise(self):
self.Xpos.setText(unicode(self.screens.current[u'size'].x()))
@ -82,82 +58,3 @@ class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog):
int(self.YposEdit.text()), int(self.WidthEdit.text()),\
int(self.HeightEdit.text()))
return QtGui.QDialog.close(self)
def onDisplayClicked(self):
if self.triggerAlert(unicode(self.AlertTextEdit.text())):
self.loadList()
def onDisplayCloseClicked(self):
if self.triggerAlert(unicode(self.AlertTextEdit.text())):
self.close()
def onDeleteClick(self):
item = self.AlertListWidget.currentItem()
if item:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.manager.delete_alert(item_id)
row = self.AlertListWidget.row(item)
self.AlertListWidget.takeItem(row)
self.AlertTextEdit.setText(u'')
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(False)
self.EditButton.setEnabled(False)
def onNewClick(self):
if len(self.AlertTextEdit.text()) == 0:
QtGui.QMessageBox.information(self,
self.trUtf8('Item selected to Add'),
self.trUtf8('Missing data'))
else:
alert = AlertItem()
alert.text = unicode(self.AlertTextEdit.text())
self.manager.save_alert(alert)
self.AlertTextEdit.setText(u'')
self.loadList()
def onSaveClick(self):
if self.item_id:
alert = self.manager.get_alert(self.item_id)
alert.text = unicode(self.AlertTextEdit.text())
self.manager.save_alert(alert)
self.item_id = None
self.loadList()
else:
self.onNewClick()
def onTextChanged(self):
#Data has changed by editing it so potential storage required
self.SaveButton.setEnabled(True)
def onDoubleClick(self):
"""
List item has been double clicked to display it
"""
items = self.AlertListWidget.selectedIndexes()
for item in items:
bitem = self.AlertListWidget.item(item.row())
self.triggerAlert(bitem.text())
self.AlertTextEdit.setText(bitem.text())
self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True)
def onSingleClick(self):
"""
List item has been single clicked to add it to
the edit field so it can be changed.
"""
items = self.AlertListWidget.selectedIndexes()
for item in items:
bitem = self.AlertListWidget.item(item.row())
self.AlertTextEdit.setText(bitem.text())
self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True)
def triggerAlert(self, text):
if text:
text = text.replace(u'<>', unicode(self.ParameterEdit.text()))
self.parent.alertsmanager.displayAlert(text)
return True
return False