Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

Commit

Permalink
Refactor new talk window to remove exec_() method
Browse files Browse the repository at this point in the history
  • Loading branch information
benbuckley committed Nov 20, 2014
1 parent 4b48801 commit 2d5ac8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
18 changes: 11 additions & 7 deletions src/freeseer/frontend/talkeditor/talkeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __init__(self, config, db):

# New Talk Widget
self.newTalkWidget.connect(self.newTalkWidget.addButton, SIGNAL('clicked()'), self.add_talk)
self.newTalkWidget.connect(self.newTalkWidget.cancelButton, SIGNAL('clicked()'), self.newTalkWidget.reject)
self.newTalkWidget.connect(self.newTalkWidget.cancelButton, SIGNAL('clicked()'), self.cancel_add)

# Load default language
actions = self.menuLanguage.actions()
Expand Down Expand Up @@ -399,7 +399,10 @@ def add_talk(self):

if presentation:
self.db.insert_presentation(presentation)
self.newTalkWidget.accept() # Close the dialog
self.newTalkWidget.hide()
#self.newTalkWidget.accept() # Close the dialog
self.apply_changes()
self.talkDetailsWidget.disable_input_fields()

def update_talk(self):
"""Updates the currently selected talk using data from the TalkEditorApp input fields"""
Expand Down Expand Up @@ -432,6 +435,10 @@ def create_presentation(self, talkDetailsWidget):
unicode(startTime.toString(Qt.ISODate)),
unicode(endTime.toString(Qt.ISODate)))

def cancel_add(self):
self.newTalkWidget.hide()
log.info('No talk added...')

def show_new_talk_popup(self):
"""Displays a modal dialog with a talk details view
Expand All @@ -442,11 +449,8 @@ def show_new_talk_popup(self):
self.clear_new_talk_fields()
self.remove_new_talk_placeholder_text()
self.newTalkWidget.talkDetailsWidget.titleLineEdit.setFocus()
if self.newTalkWidget.exec_() == 1:
self.apply_changes()
self.talkDetailsWidget.disable_input_fields()
else:
log.info('No talk added...')
self.newTalkWidget.setModal(True)
self.newTalkWidget.show()

def apply_changes(self, updated_talk=None):
"""Repopulates the model to display the effective changes
Expand Down
5 changes: 0 additions & 5 deletions src/freeseer/tests/frontend/talkeditor/test_talkeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ def test_click_talk(self):
self.assertTrue(True)

def test_click_add_talk(self):
# Click the "Add Talk" button, then click "cancel"
# This was just a test to see if it could be done -- the "exec_()" method is a bit tricky.
# This will probably be more useful in test_show_save_prompt()
#QTimer.singleShot(0, self.talk_editor.newTalkWidget.cancelButton, SLOT('click()'))
#QTest.mouseClick(self.talk_editor.commandButtons.addButton, Qt.LeftButton
self.assertTrue(True)

def test_show_save_prompt(self):
Expand Down

0 comments on commit 2d5ac8f

Please sign in to comment.