Saves the input from the editor widget to the model component.
        :qtdoc:`Re-implemented<QStyledItemDelegate.setModelData>`
774221
def setModelData(self, editor, model, index):
        """"""
        editor.saveToObject()
        # need to save over component object in stimulus model
        model.dataEdited()

        # clean up
        editor.attributesSaved.disconnect()
        if hasattr(editor, 'vocalFilesChanged'):
            editor.vocalFilesChanged.disconnect()
        editor.close()
431778
def setEditorData( self, editor, index ):
        
        item        = self.parent().itemFromIndex(index)
        value       = item.value()
        tree        = self.parent()
        querywidget = tree.parent()
        factory     = querywidget.factory()
        
        factory.setEditorData(editor, value)
1505
def setModelData(self, editor, model, index):
        
        value = editor.currentText()
        model.setData(index, wrapVariant(value))
747460
def model_saved(sender, instance,
                        created,
                        raw,
                        using,
                        **kwargs):
    
    opts = get_opts(instance)
    model = '.'.join([opts.app_label, opts.object_name])
    action = 'created' if created else 'updated'
    distill_model_event(instance, model, action)
546499
def createEditor(self, parent, column, op, value):
        
        try:
            cls = self._operatorMap[nativestring(op)].cls
        except KeyError, AttributeError:
            return None
        
        # create the new editor
        if cls:
            widget = cls(parent)
            widget.setAttribute(Qt.WA_DeleteOnClose)
            projexui.setWidgetValue(widget, value)
            return widget
        
        return None
1221174
function () {
            this.$Element.initWidget.call(this);
            this.setOptions();

            var newIndex = this.getSelectedIndexFromBindings();
            if (newIndex != null) {
                this._domElt.selectedIndex = newIndex;
            }
            this.initDisabledWidgetAttribute();

            this.__updateDataModel();
        }
1026442
def save_model(self, fname, pretty=False):
        
        with open(fname, "w") as f:
            xml_str = ET.tostring(self.root, encoding="unicode")
            if pretty:
                # TODO: get a better pretty print library
                parsed_xml = xml.dom.minidom.parseString(xml_str)
                xml_str = parsed_xml.toprettyxml(newl="")
            f.write(xml_str)
248840
function() {
      var t = this,
          val = t.editor.val();
      if (val) {
       try {
          // Throw away parse errors while typing
          t.model.set(JSON.parse(val));
        } catch (e) {
          return false;
        }
      } else {
        // Confirm deletion if user removes everything in the JSON window
        if (t.deletePage()) {
         return false;
        } else {
          // Reset source data
          t.fillSourceData();
        }
      }
      return true;
    }
749130
def save_model(self, request, page, form, change):
        
        language = form.cleaned_data['language']
        target = form.data.get('target', None)
        position = form.data.get('position', None)
        page.save()

        # if True, we need to move the page
        if target and position:
            try:
                target = self.model.objects.get(pk=target)
            except self.model.DoesNotExist:
                pass
            else:
                target.invalidate()
                page.move_to(target, position)

        for name in self.mandatory_placeholders:
            data = form.cleaned_data[name]
            placeholder = PlaceholderNode(name)
            extra_data = placeholder.get_extra_data(form.data)
            placeholder.save(page, language, data, change,
                extra_data=extra_data)

        for placeholder in get_placeholders(page.get_template()):
            if(placeholder.ctype in form.cleaned_data and placeholder.ctype
                    not in self.mandatory_placeholders):
                data = form.cleaned_data[placeholder.ctype]
                extra_data = placeholder.get_extra_data(form.data)
                placeholder.save(page, language, data, change,
                    extra_data=extra_data)

        page.invalidate()
1277850
function() {
      var value = this.input.val();
      if (!value) {
        this.clear();
      } else {
        this.model.save({title: value});
        this.$el.removeClass("editing");
      }
    }
1263613
protected void save(Model model, String filename) {
        try {
            ModelSerializer.writeModel(model, filename, true);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
252469
def save_state(self):
        
        settings = QtCore.QSettings()
        settings.setValue(
            'inasafe/useDefaultTemplates',
            self.default_template_radio.isChecked())
        settings.setValue(
            'inasafe/lastTemplate',
            self.template_combo.itemData(self.template_combo.currentIndex()))
        settings.setValue(
            'inasafe/lastCustomTemplate', self.template_path.text())
354457
def setModelData( self, editor, model, index ):
        
        tree        = self.parent()
        querywidget = tree.parent()
        factory     = querywidget.factory()
        item        = tree.itemFromIndex(index)
        
        value = factory.editorData(editor)
        item.setValue(value)
463277
def setEditorData(self, spinBox, index):
        
        if index.isValid():
            value = index.model().data(index, QtCore.Qt.EditRole)
            spinBox.setValue(value)
653266
def createEditor(self, parent, option, index):
        """"""
        if index.column() < 3:
            return None
        if self.show_warning(index):
            answer = QMessageBox.warning(self.parent(), _("Warning"),
                                      _("Opening this variable can be slow\n\n"
                                        "Do you want to continue anyway?"),
                                      QMessageBox.Yes | QMessageBox.No)
            if answer == QMessageBox.No:
                return None
        try:
            value = self.get_value(index)
            if value is None:
                return None
        except Exception as msg:
            QMessageBox.critical(self.parent(), _("Error"),
                                 _("Spyder was unable to retrieve the value of "
                                   "this variable from the console.<br><br>"
                                   "The error mesage was:<br>"
                                   "<i>%s</i>"
                                   ) % to_text_string(msg))
            return
        key = index.model().get_key(index)
        readonly = (isinstance(value, (tuple, set)) or self.parent().readonly
                    or not is_known_type(value))
        # CollectionsEditor for a list, tuple, dict, etc.
        if isinstance(value, (list, set, tuple, dict)):
            editor = CollectionsEditor(parent=parent)
            editor.setup(value, key, icon=self.parent().windowIcon(),
                         readonly=readonly)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
        # ArrayEditor for a Numpy array
        elif isinstance(value, (ndarray, MaskedArray)) \
          and ndarray is not FakeObject:
            editor = ArrayEditor(parent=parent)
            if not editor.setup_and_check(value, title=key, readonly=readonly):
                return
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
        # ArrayEditor for an images
        elif isinstance(value, Image) and ndarray is not FakeObject \
          and Image is not FakeObject:
            arr = array(value)
            editor = ArrayEditor(parent=parent)
            if not editor.setup_and_check(arr, title=key, readonly=readonly):
                return
            conv_func = lambda arr: Image.fromarray(arr, mode=value.mode)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly,
                                            conv=conv_func))
            return None
        # DataFrameEditor for a pandas dataframe, series or index
        elif isinstance(value, (DataFrame, Index, Series)) \
          and DataFrame is not FakeObject:
            editor = DataFrameEditor(parent=parent)
            if not editor.setup_and_check(value, title=key):
                return
            editor.dataModel.set_format(index.model().dataframe_format)
            editor.sig_option_changed.connect(self.change_option)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
        # QDateEdit and QDateTimeEdit for a dates or datetime respectively
        elif isinstance(value, datetime.date):
            if readonly:
                return None
            else:
                if isinstance(value, datetime.datetime):
                    editor = QDateTimeEdit(value, parent=parent)
                else:
                    editor = QDateEdit(value, parent=parent)
                editor.setCalendarPopup(True)
                editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
                return editor
        # TextEditor for a long string
        elif is_text_string(value) and len(value) > 40:
            te = TextEditor(None, parent=parent)
            if te.setup_and_check(value):
                editor = TextEditor(value, key,
                                    readonly=readonly, parent=parent)
                self.create_dialog(editor, dict(model=index.model(),
                                                editor=editor, key=key,
                                                readonly=readonly))
            return None
        # QLineEdit for an individual value (int, float, short string, etc)
        elif is_editable_type(value):
            if readonly:
                return None
            else:
                editor = QLineEdit(parent=parent)
                editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
                editor.setAlignment(Qt.AlignLeft)
                # This is making Spyder crash because the QLineEdit that it's
                # been modified is removed and a new one is created after
                # evaluation. So the object on which this method is trying to
                # act doesn't exist anymore.
                # editor.returnPressed.connect(self.commitAndCloseEditor)
                return editor
        # CollectionsEditor for an arbitrary Python object
        else:
            editor = CollectionsEditor(parent=parent)
            editor.setup(value, key, icon=self.parent().windowIcon(),
                         readonly=readonly)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
1061798
protected function saveEditor()
    {
        $this->controlAccessSaveEditor();

        $submitted = $this->getSubmitted();
        $result = $this->editor->save($submitted);

        if ($result === true) {
            $message = $this->text('File has been saved');
            $this->redirect("admin/tool/editor/{$submitted['module']['id']}", $message, 'success');
        }

        $this->redirect('', $this->text('An error occurred'), 'warning');
    }
310416
def _saveModel(self):
        
        delimiter = self._delimiterBox.currentSelected()
        header = self._headerCheckBox.isChecked() # column labels
        if self._filename is None:
            filename = self._filenameLineEdit.text()
        else:
            filename = self._filename
        ext = os.path.splitext(filename)[1].lower()
        index = False # row labels

        encodingIndex = self._encodingComboBox.currentIndex()
        encoding = self._encodingComboBox.itemText(encodingIndex)
        encoding = _calculateEncodingKey(encoding.lower())

        try:
            dataFrame = self._model.dataFrame()
        except AttributeError as err:
            raise AttributeError('No data loaded to export.')
        else:
            print("Identifying export type for {}".format(filename))
            try:
                if ext in ['.txt','.csv']:
                    dataFrame.to_csv(filename, encoding=encoding, header=header, index=index, sep=delimiter)
                elif ext == '.tsv':
                    sep = '\t'
                    dataFrame.to_csv(filename, encoding=encoding, header=header, index=index, sep=delimiter)
                elif ext in ['.xlsx','.xls']:
                    dataFrame.to_excel(filename, encoding=encoding, header=header, index=index, sep=delimiter)
            except IOError as err:
                raise IOError('No filename given')
            except UnicodeError as err:
                raise UnicodeError('Could not encode all data. Choose a different encoding')
            except Exception:
                raise
            self.signalExportFilenames.emit(self._model._filePath, filename)