Package Camelot :: Package camelot :: Package view :: Package controls :: Package editors :: Module abstractmanytooneeditor |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.controls.editors.abstractmanytooneeditor

     1  from PyQt4 import QtGui, QtCore
     2

     3 -class AbstractManyToOneEditor(object):
     4      """Helper functions for implementing a `ManyToOneEditor`, to be used in the

     5    `ManyToOneEditor` and in the `ManyToManyEditor`

     6    """
     7

     8 -    def createSelectView(self):
     9          #search_text = unicode(self.search_input.text())

    10          search_text = ''
    11          admin = self.admin
    12          query = self.admin.entity.query
    13

    14          class SelectDialog(QtGui.QDialog):
    15              def __init__(self, parent):
    16                  super(SelectDialog, self).__init__(parent)
    17                  self.entity_selected_signal = QtCore.SIGNAL("entity_selected")
    18                  layout = QtGui.QVBoxLayout()
    19                  layout.setMargin(0)
    20                  layout.setSpacing(0)
    21                  self.setWindowTitle('Select %s'%admin.get_verbose_name())
    22                  self.select = admin.create_select_view(query,

    23                                                         parent=parent,

    24                                                         search_text=search_text)
    25                  layout.addWidget(self.select)
    26                  self.setLayout(layout)
    27                  self.connect(self.select, self.select.entity_selected_signal, self.selectEntity)
    28

    29              def selectEntity(self, entity_instance_getter):
    30                  self.emit(self.entity_selected_signal, entity_instance_getter)
    31                  self.close()
    32

    33          selectDialog = SelectDialog(self)
    34          self.connect(selectDialog, selectDialog.entity_selected_signal, self.selectEntity)
    35          selectDialog.exec_()
    36

    37 -    def selectEntity(self, entity_instance_getter):
    38          #raise Exception('Not implemented')

    39          raise NotImplementedError
    40