def accept(self):
     # Override accept so we can first validate
     if self.is_valid():
         category_name = self.addEditCatLineEdit.text().strip()
         try:
             with session_scope() as session:
                 if self.edit_cat_id is not None:
                     category = session.query(Category).get(
                         int(self.edit_cat_id))
                     category.category_name = category_name
                     logger.debug('Edited cat with id %s' %
                                  self.edit_cat_id)
                 else:
                     category = Category(category_name=category_name)
                     session.add(category)
                     logger.debug('Added cat with name %s' % category_name)
         except exc.IntegrityError as int_exc:
             logger.debug(int_exc)
             QMessageBox.warning(self, "Already exists warning",
                                 unicode('This category already exists'))
             self.addEditCatLineEdit.setFocus()
             self.selectAll()
             return
         except Exception as uexc:
             logger.error(str(uexc))
             QMessageBox.warning(self, "Unexpected Error",
                                 unicode('Could not edit category.'))
             return
         else:
             # All good, accept after triggering tree refresh with sig
             self.categories_changed.emit()
             QDialog.accept(self)
Beispiel #2
0
    def accept(self):
        """Accept event."""

        while str(self.ui.lineEditPath.text()) == '':
            self.searchPath()

        self.preferences['title'] = self.ui.lineEditTitle.text()
        self.preferences['author'] = str(self.ui.lineEditAuthor.text())
        self.preferences['description'] = str(
            self.ui.textEditDescription.toPlainText())

        self.preferences['pdf'] = {}
        self.preferences['pdf']['path'] = str(self.ui.lineEditPath.text())
        self.preferences['pdf'][
            'auto_open'] = self.ui.checkBoxAutoOpen.isChecked()

        self.preferences['pdf']['mode'] = self.ui.comboBoxMode.currentText()

        self.preferences['pdf'][
            'margin_left'] = self.ui.doubleSpinBoxLeft.value()
        self.preferences['pdf'][
            'margin_right'] = self.ui.doubleSpinBoxRight.value()
        self.preferences['pdf']['margin_top'] = self.ui.doubleSpinBoxTop.value(
        )
        self.preferences['pdf'][
            'margin_bottom'] = self.ui.doubleSpinBoxBottom.value()

        self.preferences['pdf']['font'] = self.ui.comboBoxFont.currentText()
        self.preferences['pdf']['size'] = self.ui.spinBoxSize.value()

        QDialog.accept(self)
Beispiel #3
0
    def accept(self):
        players = self.playerSelections()
        self.team.team_name = self.teamNameEdit.text()
        self.team.email = unicode(self.emailEdit.text()).lower()

        if self.validTeam(players):
            playersOut = [player for player in self.team_players if player not in players]
            subs_made = len(playersOut)
            if subs_made > 0:
                if self.team.subs_used + subs_made > config.MAX_SUBS:
                    QMessageBox.critical(self, "Substitution Error",
                                         "This manager has insufficient substitutions remaining")
                    self.setCurrentPlayers()
                else:
                    playersIn = [player for player in players if player not in self.team_players]
                    form = confirmSubsDialog(playersOut, playersIn, self)
                    if form.exec_():
                        self.team.subs_used += subs_made
                        self.team.total_cost = self.total_cost
                        self.team.formation = self.formation
                        self.team.squad.substitute(playersIn, playersOut, form.datetime)
                        self.confirmSubs(playersIn, playersOut, form.datetime)
                        QDialog.accept(self)
                    else:
                        self.setCurrentPlayers()
            else:
                QDialog.accept(self)

        self.team.save()
Beispiel #4
0
 def accept(self):
     settings = QSettings()
     settings.setValue("DB/File", self.file.text())
     settings.setValue("SMTP/Server", self.smtp_server.text())
     settings.setValue("HTTP Proxy/IP", self.http_proxy_ip.text())
     settings.setValue("HTTP Proxy/Enabled", bool(self.http_proxy.isChecked()) and bool(self.http_proxy_ip.text()))
     QDialog.accept(self)
    def accept(self, *args, **kwargs):
        #Validate the input, returning if invalid.

        #The configuration name cannot be empty or only whitespace.
        configuration_name = self.txtName.text().strip()
        if not configuration_name:
            QMessageBox.critical(self, "Missing Name", "You must give this server configuration a name.")
            self.txtName.selectAll()
            self.txtName.setFocus()
            return

        #We check to see if the user entered a valid server configuration.
        if self.ServerTypeTabs.currentWidget() is self.LocalServerTab:
            if not self.validateLocalServerPath():
                QMessageBox.critical(self, "Invalid Path", "The path you entered does not point to a valid Sage installation.")
                self.txtPath.selectAll()
                self.txtPath.setFocus()
                return
        elif self.ServerTypeTabs.currentWidget() is self.NotebookServerTab:
            if not self.validateNotebookServer():
                QMessageBox.critical(self, "Invalid Notebook Server", "The Sage Notebook Server settings you provided are not valid.")
                return


        #Input is valid, so accept.
        QDialog.accept(self)
    def accept(self):
        self.network_changed = self.networkWidget.is_changed()
        self.rep_changed = self.repWidget.is_changed()
        self.specgram_changed = self.specWidget.is_changed()

        self.settings.update(self.networkWidget.get_current_state())
        self.settings.update(self.repWidget.get_current_state())
        self.settings.update(self.specWidget.get_current_state())

        QDialog.accept(self)
Beispiel #7
0
 def accept(self):
     settings = QSettings()
     settings.setValue("DB/File", self.file.text())
     settings.setValue("SMTP/Server", self.smtp_server.text())
     settings.setValue("HTTP Proxy/IP", self.http_proxy_ip.text())
     settings.setValue(
         "HTTP Proxy/Enabled",
         bool(self.http_proxy.isChecked())
         and bool(self.http_proxy_ip.text()))
     QDialog.accept(self)
Beispiel #8
0
	def accept(self):
		if len(self.id_lineedit.text().strip()) == 0:
			QMessageBox.warning(self, "Error: Relief Device ID Blank", "The relief device must be given an ID.", QMessageBox.Ok)
			self.id_lineedit.setFocus()
			return
		selected_area = self.area_combobox.itemData(self.area_combobox.currentIndex())
		for device in selected_area.children:
			if device.name == self.id_lineedit.text():
				QMessageBox.warning(self, "Error: Relief Device ID Already Exists", 
				"Cannot add relief device because that relief device ID already exists. Please create a new relief device ID.", QMessageBox.Ok)
				self.id_lineedit.setFocus()
				self.id_lineedit.setSelection(0, self.id_lineedit.maxLength())
				return
		QDialog.accept(self)
Beispiel #9
0
 def accept(self, *args, **kwargs):
     """
     Commit changes and disposes the dialog.
     """
     # Save the options.
     self.save()
     return QDialog.accept(self, *args, **kwargs)
Beispiel #10
0
 def accept(self):
     error = False
     self.playersOut = []
     for i,p in enumerate(self.formationChanges):
         if p > 0:
             checked = [(player,checkBox) for (player,checkBox)
                        in self.allCheckBoxes[i].items() if checkBox.isChecked()]
             if len(checked) != p:
                 error = True
                 message = "Choose {0} {1}".format(p, Formation.labels[i])
                 if p > 1:
                     message+"s"
                 QMessageBox.critical(self, "Error", message)
             else:
                 self.playersOut.extend([player for (player,checkBox) in checked])
                 
     if not error:
         QDialog.accept(self)
Beispiel #11
0
	def accept(self):
		if len(self.name_lineedit.text().strip()) == 0:
			QMessageBox.warning(self, "Error: Relief Device Area Name Blank", "The relief device area must be given a name.", QMessageBox.Ok)
			self.name_lineedit.setFocus()
			return
		if len(self.location_combobox.currentText().strip()) == 0:
			QMessageBox.warning(self, "Error: Location Blank", "You must save the relief device area file to a valid directory.", QMessageBox.Ok)
			self.location_combobox.setFocus()
			return
		if not os.path.exists(self.location_combobox.currentText().replace("\\", "/")):
			QMessageBox.warning(self, "Error: Directory Does Not Exist", "The specified directory does not exist.", QMessageBox.Ok)
			self.location_combobox.setFocus()
			return
		if os.path.isfile(self.location_combobox.currentText().replace("\\", "/") + "/" + self.name_lineedit.text() + ".rda"):
			if QMessageBox.question(self, "File Already Exists", 
			"The file {0} already exists at {1}. Are you sure you want to proceed and overwrite this file?".format(self.name_lineedit.text() + ".rda", 
			self.location_combobox.currentText().replace("\\", "/")), QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
				self.name_lineedit.setFocus()
				return
		QDialog.accept(self)
Beispiel #12
0
    def accept(self):
        error = False
        self.playersOut = []
        for i, p in enumerate(self.formationChanges):
            if p > 0:
                checked = [(player, checkBox)
                           for (player,
                                checkBox) in self.allCheckBoxes[i].items()
                           if checkBox.isChecked()]
                if len(checked) != p:
                    error = True
                    message = "Choose {0} {1}".format(p, Formation.labels[i])
                    if p > 1:
                        message + "s"
                    QMessageBox.critical(self, "Error", message)
                else:
                    self.playersOut.extend(
                        [player for (player, checkBox) in checked])

        if not error:
            QDialog.accept(self)
    def accept(self):
        """Accept event."""
        self.preferences['theme'] = self.ui.comboBoxTheme.currentText()
        self.preferences['marker'] = str(self.ui.comboBoxMarker.currentText())
        self.preferences['where'] = str(self.ui.comboBoxWhere.currentText())
        self.preferences['mode'] = str(self.ui.comboBoxMode.currentText())
        self.preferences['replace_by'] = str(self.ui.lineEditReplaceBy.text())
        self.workspace = str(self.ui.lineEditWorkspace.text())

        os_sys = platform.system()
        if os_sys == 'Windows':
            self.preferences['win_workspace'] = self.workspace
        if os_sys == 'Linux':
            self.preferences['lin_workspace'] = self.workspace
        if os_sys == 'Mac':
            self.preferences['mac_workspace'] = self.workspace

        self.preferences['open_last'] = self.ui.checkBoxOpenLast.isChecked()

        if not os.path.exists(self.workspace):
            os.makedirs(self.workspace)

        QDialog.accept(self)
Beispiel #14
0
    def accept(self):
        players = self.playerSelections()
        self.team.team_name = self.teamNameEdit.text()
        self.team.email = unicode(self.emailEdit.text()).lower()

        if self.validTeam(players):
            playersOut = [
                player for player in self.team_players if player not in players
            ]
            subs_made = len(playersOut)
            if subs_made > 0:
                if self.team.subs_used + subs_made > config.MAX_SUBS:
                    QMessageBox.critical(
                        self, "Substitution Error",
                        "This manager has insufficient substitutions remaining"
                    )
                    self.setCurrentPlayers()
                else:
                    playersIn = [
                        player for player in players
                        if player not in self.team_players
                    ]
                    form = confirmSubsDialog(playersOut, playersIn, self)
                    if form.exec_():
                        self.team.subs_used += subs_made
                        self.team.total_cost = self.total_cost
                        self.team.formation = self.formation
                        self.team.squad.substitute(playersIn, playersOut,
                                                   form.datetime)
                        self.confirmSubs(playersIn, playersOut, form.datetime)
                        QDialog.accept(self)
                    else:
                        self.setCurrentPlayers()
            else:
                QDialog.accept(self)

        self.team.save()
Beispiel #15
0
 def __guardar(self):
     guardar = True
     p = Persistence()
     if self.__categoria is None:
         categoria = Categoria()
         categoria.setDescripcion(self.txtCategoria.text())
         self.__categoria = categoria
     else:
         self.__categoria.setDescripcion(self.txtCategoria.text())
         guardar = False        
     try:
         if guardar:
             p.guardarCategoria(categoria)
         else:
             p.actualizarCategoria(self.__categoria)
     except sqlite3.IntegrityError:
         if guardar:
             self.__categoria = None
         QMessageBox.information(self, 'Error', 'El elemento ya existe')
     else:
         return QDialog.accept(self)
Beispiel #16
0
 def accept(self):
     " User accepts. Raise accepted flag in settings. "
     settings = QSettings()
     settings.setValue(self.flagSettingName, True)
     QDialog.accept(self)  # super close dialog
Beispiel #17
0
 def accept(self):
     self.datetime = self.dateTimeEdit.dateTime().toPython()
     QDialog.accept(self)
Beispiel #18
0
 def accept(self):
     self.datetime = self.dateTimeEdit.dateTime().toPython()
     QDialog.accept(self)
Beispiel #19
0
 def accept(self):
     self.mapper.submit()
     QDialog.accept(self)
Beispiel #20
0
 def accept(self):
     QDialog.accept(self)