예제 #1
0
    def __init__(self, parent=None, field_name='richtext', **kwargs):
        CustomEditor.__init__(self, parent)
        self.setObjectName(field_name)
        self.layout = QtGui.QVBoxLayout(self)
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Expanding)

        self.textedit = CustomTextEdit(self)

        self.initToolbar()  # Has to be invoked before the connect's below.
        self.toolbar.hide()  # Should only be visible when textedit is focused.

        self.textedit.editingFinished.connect(self.emit_editing_finished)
        self.textedit.receivedFocus.connect(self.toolbar.show)
        self.textedit.setAcceptRichText(True)

        # Layout
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.textedit)
        self.setLayout(self.layout)

        # Format
        self.textedit.setFontWeight(QtGui.QFont.Normal)
        self.textedit.setFontItalic(False)
        self.textedit.setFontUnderline(False)
        #self.textedit.setFocus(Qt.OtherFocusReason)
        self.update_alignment()
        self.textedit.currentCharFormatChanged.connect(self.update_format)
        self.textedit.cursorPositionChanged.connect(self.update_text)
예제 #2
0
    def __init__(self, parent=None, storage=None, remove_original=False, 
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self.storage = storage

        # i'm a < 80 characters fanatic, i know :)
        self.new_icon = Icon(
            'tango/16x16/actions/list-add.png'
        ).getQIcon()
        self.open_icon = Icon(
            'tango/16x16/actions/document-open.png'
        ).getQIcon()
        self.clear_icon = Icon(
            'tango/16x16/actions/edit-delete.png'
        ).getQIcon()
        self.save_as_icon = Icon(
            'tango/16x16/actions/document-save-as.png'
        ).getQIcon()
        self.document_pixmap = Icon(
            'tango/16x16/mimetypes/x-office-document.png'
        ).getQPixmap()

        self.value = None
        self.remove_original = remove_original
        self.setup_widget()
예제 #3
0
    def __init__(self, 
                 parent, 
                 editable = True, 
                 icons = default_icons, 
                 field_name = 'icons',
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self.setObjectName( field_name )
        self.box = QtGui.QComboBox()
        self.box.setFrame(True)
        self.box.setEditable(False)
        self.name_by_position = {0:None}
        self.position_by_name = {None:0}

        self.box.addItem('')
        for i,(icon_name, icon) in enumerate(icons):
            self.name_by_position[i+1] = icon_name
            self.position_by_name[icon_name] = i+1
            self.box.addItem(icon.getQIcon(), '')
            self.box.setFixedHeight(self.get_height())

        self.setFocusPolicy(Qt.StrongFocus)
        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins( 0, 0, 0, 0)
        layout.setSpacing(0)
        self.setAutoFillBackground(True)
        if not editable:
            self.box.setEnabled(False)
        else:
            self.box.setEnabled(True)

        self.box.activated.connect( self.smiley_changed )
        layout.addWidget(self.box)
        layout.addStretch()
        self.setLayout(layout)
예제 #4
0
    def __init__(self, parent=None, editable=True, address_type=None, **kwargs):
        CustomEditor.__init__(self, parent)
        self._address_type = address_type
        self.layout = QtGui.QHBoxLayout()
        self.layout.setMargin(0)
        self.combo = QtGui.QComboBox()
        self.combo.addItems(camelot.types.VirtualAddress.virtual_address_types)
        self.combo.setEnabled(editable)
        if address_type:
            self.combo.setVisible(False)
        self.layout.addWidget(self.combo)
        self.editor = QtGui.QLineEdit()
        self.editor.setEnabled(editable)
        self.layout.addWidget(self.editor)
        self.setFocusProxy(self.editor)
        self.editable = editable
        nullIcon = Icon('tango/16x16/apps/internet-mail.png').getQIcon()
        self.label = QtGui.QToolButton()
        self.label.setIcon(nullIcon)
        self.label.setAutoFillBackground(False)
        self.label.setAutoRaise(True)
        self.label.setEnabled(False)
        self.label.setToolButtonStyle(Qt.ToolButtonIconOnly)

        self.layout.addWidget(self.label)
        self.editor.editingFinished.connect(self.emit_editing_finished)
        self.editor.textEdited.connect(self.editorValueChanged)
        self.combo.currentIndexChanged.connect(self.comboIndexChanged)

        self.setLayout(self.layout)
        self.setAutoFillBackground(True)
        self.checkValue(self.editor.text())
예제 #5
0
    def __init__(self, parent, editable=True, nullable=True, **kwargs):
        CustomEditor.__init__(self, parent)
        import itertools
        self.nullable = nullable

        layout = QtGui.QHBoxLayout()
        self.dateedit = DateEditor(self,
                                   editable=editable,
                                   nullable=nullable,
                                   **kwargs)
        self.dateedit.editingFinished.connect(self.editing_finished)
        layout.addWidget(self.dateedit, 1)

        self.timeedit = QtGui.QComboBox(self)
        self.timeedit.setEditable(True)
        if not editable:
            self.timeedit.setEnabled(False)

        time_entries = [
            entry for entry in itertools.chain(*(('%02i:00' % i, '%02i:30' % i)
                                                 for i in range(0, 24)))
        ]
        self.timeedit.addItems(time_entries)
        self.timeedit.setValidator(TimeValidator(self, nullable))
        self.timeedit.currentIndexChanged.connect(self.editing_finished)
        self.timeedit.editTextChanged.connect(self.editing_finished)
        self.timeedit.setFocusPolicy(Qt.StrongFocus)

        layout.addWidget(self.timeedit, 1)
        # focus proxy is needed to activate the editor with a single click
        self.setFocusProxy(self.dateedit)
        self.setLayout(layout)
        layout.setMargin(0)
        layout.setSpacing(0)
예제 #6
0
 def __init__(self,
              parent=None,
              parts=['99', 'AA'],
              editable=True,
              **kwargs):
     CustomEditor.__init__(self, parent)
     self.parts = parts
     self.part_editors = []
     layout = QtGui.QHBoxLayout()
     layout.setMargin(0)
     layout.setSpacing(0)
     layout.setAlignment(Qt.AlignLeft)
     for i, part in enumerate(parts):
         part = re.sub('\W*', '', part)
         part_length = len(part)
         editor = PartEditor(part)
         editor.setFocusPolicy(Qt.StrongFocus)
         if i == 0:
             self.setFocusProxy(editor)
         if not editable:
             editor.setEnabled(False)
         space_width = editor.fontMetrics().size(Qt.TextSingleLine,
                                                 'A').width()
         editor.setMaximumWidth(space_width * (part_length + 1))
         self.part_editors.append(editor)
         layout.addWidget(editor)
         editor.editingFinished.connect(self.emit_editing_finished)
     self.setLayout(layout)
예제 #7
0
    def __init__(self, parent, maximum=5, editable=True, **kwargs):
        CustomEditor.__init__(self, parent)
        self.setFocusPolicy(Qt.StrongFocus)
        layout = QtGui.QHBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        self.starCount = 5
        self.buttons = []
        for i in range(self.starCount):
            button = QtGui.QToolButton(self)
            button.setIcon(self.no_star_icon.getQIcon())
            button.setFocusPolicy(Qt.ClickFocus)
            if editable:
                button.setAutoRaise(True)
            else:
                button.setAutoRaise(True)
                button.setDisabled(True)
            button.setFixedHeight(self.get_height())
            self.buttons.append(button)

        def createStarClick(i):
            return lambda:self.starClick(i+1)

        for i in range(self.starCount):
            self.buttons[i].clicked.connect(createStarClick(i))

        for i in range(self.starCount):
            layout.addWidget(self.buttons[i])
        layout.addStretch()
        self.setLayout(layout)
예제 #8
0
 def __init__(self,
              parent=None,
              parts=['99', 'AA'],
              editable=True,
              field_name='code',
              **kwargs):
     CustomEditor.__init__(self, parent)
     self.setObjectName(field_name)
     self.value = None
     self.parts = parts
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     layout.setAlignment(Qt.AlignLeft)
     for i, part in enumerate(parts):
         part = re.sub('\W*', '', part)
         part_length = len(part)
         editor = PartEditor(part, part_length, i == 0,
                             i == (len(parts) - 1))
         editor.setFocusPolicy(Qt.StrongFocus)
         if i == 0:
             self.setFocusProxy(editor)
         if not editable:
             editor.setEnabled(False)
         space_width = editor.fontMetrics().size(Qt.TextSingleLine,
                                                 'A').width()
         editor.setMaximumWidth(space_width * (part_length + 1))
         editor.setObjectName('part_%i' % i)
         layout.addWidget(editor)
         editor.editingFinished.connect(self.emit_editing_finished)
     self.setLayout(layout)
예제 #9
0
  
    def __init__(self,
                 parent,
                 editable=True,
                 nullable=True,
                 **kwargs):
        CustomEditor.__init__(self, parent)
        import itertools
        self.nullable = nullable
        layout = QtGui.QHBoxLayout()
        self.dateedit = DateEditor(self, editable=editable, nullable=nullable, **kwargs)
        self.dateedit.editingFinished.connect( self.editing_finished )
        layout.addWidget(self.dateedit, 1)

        self.timeedit = QtGui.QComboBox(self)
        self.timeedit.setEditable(True)
        if not editable:
            self.timeedit.setEnabled(False)
        
        time_entries = [entry
                        for entry in itertools.chain(*(('%02i:00'%i, '%02i:30'%i)
                        for i in range(0,24)))]
        self.timeedit.addItems(time_entries)
        self.timeedit.setValidator(TimeValidator(self, nullable))
        self.timeedit.currentIndexChanged.connect( self.editing_finished )
        self.timeedit.editTextChanged.connect( self.editing_finished )
        self.timeedit.setFocusPolicy( Qt.StrongFocus )

        layout.addWidget(self.timeedit, 1)
        # focus proxy is needed to activate the editor with a single click
        self.setFocusProxy(self.dateedit)
        self.setLayout(layout)
예제 #10
0
    def __init__(self, 
                 parent = None, 
                 field_name = 'richtext',
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self.setObjectName( field_name )
        self.layout = QtGui.QVBoxLayout(self)
        self.layout.setSpacing(0)
        self.layout.setContentsMargins( 0, 0, 0, 0)
        self.setSizePolicy( QtGui.QSizePolicy.Expanding,
                            QtGui.QSizePolicy.Expanding )

        self.textedit = CustomTextEdit(self)

        self.initToolbar() # Has to be invoked before the connect's below.
        self.toolbar.hide() # Should only be visible when textedit is focused.
        
        self.textedit.editingFinished.connect(self.emit_editing_finished)
        self.textedit.receivedFocus.connect(self.toolbar.show)
        self.textedit.setAcceptRichText(True)
        
        # Layout
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.textedit)
        self.setLayout(self.layout)

        # Format
        self.textedit.setFontWeight(QtGui.QFont.Normal)
        self.textedit.setFontItalic(False)
        self.textedit.setFontUnderline(False)
        #self.textedit.setFocus(Qt.OtherFocusReason)
        self.update_alignment()
        self.textedit.currentCharFormatChanged.connect(self.update_format)
        self.textedit.cursorPositionChanged.connect(self.update_text)
예제 #11
0
    def __init__(self, parent=None, **kwargs):
        CustomEditor.__init__(self, parent)
        self.layout = QtGui.QVBoxLayout(self)
        self.layout.setSpacing(0)
        self.layout.setMargin(0)
        self.setSizePolicy( QtGui.QSizePolicy.Expanding,
                            QtGui.QSizePolicy.Expanding )

        class CustomTextEdit(QtGui.QTextEdit):
            """A TextEdit editor that sends editingFinished events when the text was changed
            and focus is lost
            """

            editingFinished = QtCore.pyqtSignal()
            
            def __init__(self, parent):
                super(CustomTextEdit, self).__init__(parent)
                self._changed = False
                self.setTabChangesFocus( True )
                self.textChanged.connect( self._handle_text_changed )

            def focusOutEvent(self, event):
                if self._changed:
                    self.editingFinished.emit()
                super(CustomTextEdit, self).focusOutEvent( event )

            def _handle_text_changed(self):
                self._changed = True

            def setTextChanged(self, state=True):
                self._changed = state

            def setHtml(self, html):
                QtGui.QTextEdit.setHtml(self, html)
                self._changed = False

        self.textedit = CustomTextEdit(self)

        self.textedit.editingFinished.connect( self.emit_editing_finished )
        self.textedit.setAcceptRichText(True)
        self.initButtons()
#      #
#      # Layout
#      #
#      self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.textedit)

        self.setLayout(self.layout)

        #
        # Format
        #
        self.textedit.setFontWeight(QtGui.QFont.Normal)
        self.textedit.setFontItalic(False)
        self.textedit.setFontUnderline(False)
        #self.textedit.setFocus(Qt.OtherFocusReason)
        self.update_alignment()
        self.textedit.currentCharFormatChanged.connect(self.update_format)
        self.textedit.cursorPositionChanged.connect(self.update_text)
예제 #12
0
    def __init__(self, parent=None, **kwargs):
        CustomEditor.__init__(self, parent)
        self.layout = QtGui.QVBoxLayout(self)
        self.layout.setSpacing(0)
        self.layout.setMargin(0)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Expanding)

        class CustomTextEdit(QtGui.QTextEdit):
            """A TextEdit editor that sends editingFinished events when the text was changed
            and focus is lost
            """

            editingFinished = QtCore.pyqtSignal()

            def __init__(self, parent):
                super(CustomTextEdit, self).__init__(parent)
                self._changed = False
                self.setTabChangesFocus(True)
                self.textChanged.connect(self._handle_text_changed)

            def focusOutEvent(self, event):
                if self._changed:
                    self.editingFinished.emit()
                super(CustomTextEdit, self).focusOutEvent(event)

            def _handle_text_changed(self):
                self._changed = True

            def setTextChanged(self, state=True):
                self._changed = state

            def setHtml(self, html):
                QtGui.QTextEdit.setHtml(self, html)
                self._changed = False

        self.textedit = CustomTextEdit(self)

        self.textedit.editingFinished.connect(self.emit_editing_finished)
        self.textedit.setAcceptRichText(True)
        self.initButtons()
        #      #
        #      # Layout
        #      #
        #      self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.textedit)

        self.setLayout(self.layout)

        #
        # Format
        #
        self.textedit.setFontWeight(QtGui.QFont.Normal)
        self.textedit.setFontItalic(False)
        self.textedit.setFontUnderline(False)
        #self.textedit.setFocus(Qt.OtherFocusReason)
        self.update_alignment()
        self.textedit.currentCharFormatChanged.connect(self.update_format)
        self.textedit.cursorPositionChanged.connect(self.update_text)
예제 #13
0
 def __init__(self, parent=None, storage=None, field_name="file", remove_original=False, **kwargs):
     CustomEditor.__init__(self, parent)
     self.setObjectName(field_name)
     self.storage = storage
     self.filename = None  # the widget containing the filename
     self.value = None
     self.remove_original = remove_original
     self.setup_widget()
예제 #14
0
    def __init__(self, parent = None,
                       editable = True,
                       nullable = True, 
                       field_name = 'date',
                       **kwargs):
        CustomEditor.__init__(self, parent)

        self.setObjectName( field_name )
        self.date_format = local_date_format()
        self.line_edit = DecoratedLineEdit()
        self.line_edit.set_minimum_width( len( self.date_format ) )
        self.line_edit.set_background_text( QtCore.QDate(2000,1,1).toString(self.date_format) )

        # The order of creation of this widgets and their parenting
        # seems very sensitive under windows and creates system crashes
        # so don't change this without extensive testing on windows
        special_date_menu = QtGui.QMenu(self)
        calendar_widget_action = QtGui.QWidgetAction(special_date_menu)
        self.calendar_widget = QtGui.QCalendarWidget(special_date_menu)
        self.calendar_widget.activated.connect(self.calendar_widget_activated)
        self.calendar_widget.clicked.connect(self.calendar_widget_activated)
        calendar_widget_action.setDefaultWidget(self.calendar_widget)

        self.calendar_action_trigger.connect( special_date_menu.hide )
        special_date_menu.addAction(calendar_widget_action)
        special_date_menu.addAction(_('Today'))
        special_date_menu.addAction(_('Far future'))
        self.special_date = QtGui.QToolButton(self)
        self.special_date.setIcon( self.special_date_icon.getQIcon() )
        self.special_date.setAutoRaise(True)
        self.special_date.setToolTip(_('Calendar and special dates'))
        self.special_date.setMenu(special_date_menu)
        self.special_date.setPopupMode(QtGui.QToolButton.InstantPopup)
        self.special_date.setFixedHeight(self.get_height())
        self.special_date.setFocusPolicy(Qt.ClickFocus)
        # end of sensitive part

        if nullable:
            special_date_menu.addAction(_('Clear'))

        self.hlayout = QtGui.QHBoxLayout()
        self.hlayout.addWidget(self.line_edit)
        self.hlayout.addWidget(self.special_date)

        self.hlayout.setContentsMargins(0, 0, 0, 0)
        self.hlayout.setSpacing(0)
        self.hlayout.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
        
        self.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.hlayout)

        self.minimum = datetime.date.min
        self.maximum = datetime.date.max
        self.setFocusProxy(self.line_edit)

        self.line_edit.editingFinished.connect( self.line_edit_finished )
        self.line_edit.textEdited.connect(self.text_edited)
        special_date_menu.triggered.connect(self.set_special_date)
예제 #15
0
    def __init__(self,
                 parent=None,
                 editable=True,
                 nullable=True,
                 **kwargs):
        CustomEditor.__init__(self, parent)

        self.date_format = local_date_format()
        self.line_edit = DecoratedLineEdit()
        self.line_edit.set_background_text( QtCore.QDate(2000,1,1).toString(self.date_format) )

        # The order of creation of this widgets and their parenting
        # seems very sensitive under windows and creates system crashes
        # so don't change this without extensive testing on windows
        special_date_menu = QtGui.QMenu(self)
        calendar_widget_action = QtGui.QWidgetAction(special_date_menu)
        self.calendar_widget = QtGui.QCalendarWidget(special_date_menu)
        self.calendar_widget.activated.connect(self.calendar_widget_activated)
        self.calendar_widget.clicked.connect(self.calendar_widget_activated)
        calendar_widget_action.setDefaultWidget(self.calendar_widget)

        self.calendar_action_trigger.connect( special_date_menu.hide )
        special_date_menu.addAction(calendar_widget_action)
        special_date_menu.addAction(_('Today'))
        special_date_menu.addAction(_('Far future'))
        self.special_date = QtGui.QToolButton(self)
        self.special_date.setIcon( self.special_date_icon.getQIcon() )
        self.special_date.setAutoRaise(True)
        self.special_date.setToolTip(_('Calendar and special dates'))
        self.special_date.setMenu(special_date_menu)
        self.special_date.setPopupMode(QtGui.QToolButton.InstantPopup)
        self.special_date.setFixedHeight(self.get_height())
        self.special_date.setFocusPolicy(Qt.ClickFocus)
        # end of sensitive part

        if nullable:
            special_date_menu.addAction(_('Clear'))

        self.hlayout = QtGui.QHBoxLayout()
        self.hlayout.addWidget(self.line_edit)
        self.hlayout.addWidget(self.special_date)

        self.hlayout.setContentsMargins(0, 0, 0, 0)
        self.hlayout.setMargin(0)
        self.hlayout.setSpacing(0)
        self.hlayout.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
        
        self.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.hlayout)

        self.minimum = datetime.date.min
        self.maximum = datetime.date.max
        self.setFocusProxy(self.line_edit)

        self.line_edit.editingFinished.connect( self.line_edit_finished )
        self.line_edit.textEdited.connect(self.text_edited)
        special_date_menu.triggered.connect(self.set_special_date)
예제 #16
0
 def __init__(self, parent=None, editable=True, **kwargs):
     CustomEditor.__init__(self, parent)
     layout = QtGui.QVBoxLayout(self)
     layout.setSpacing(0)
     layout.setMargin(0)
     self.color_button = QtGui.QPushButton(parent)
     self.color_button.setMaximumSize(QtCore.QSize(20, 20))
     layout.addWidget(self.color_button)
     if editable:
         self.color_button.clicked.connect(self.buttonClicked)
     self.setLayout(layout)
     self._color = None
예제 #17
0
 def __init__(self, parent=None, editable=True, **kwargs):
     CustomEditor.__init__(self, parent)
     layout = QtGui.QVBoxLayout(self)
     layout.setSpacing(0)
     layout.setMargin(0)
     self.color_button = QtGui.QPushButton(parent)
     self.color_button.setMaximumSize(QtCore.QSize(20, 20))
     layout.addWidget(self.color_button)
     if editable:
         self.color_button.clicked.connect(self.buttonClicked)
     self.setLayout(layout)
     self._color = None
예제 #18
0
 def __init__(self,
              parent=None,
              field_name='local_file',
              directory=False,
              save_as=False,
              file_filter='All files (*)',
              **kwargs):
     CustomEditor.__init__(self, parent)
     self.setObjectName(field_name)
     self._directory = directory
     self._save_as = save_as
     self._file_filter = file_filter
     self.setup_widget()
예제 #19
0
 def __init__(self,
              parent=None,
              storage=None,
              field_name='file',
              remove_original=False,
              **kwargs):
     CustomEditor.__init__(self, parent)
     self.setObjectName(field_name)
     self.storage = storage
     self.filename = None  # the widget containing the filename
     self.value = None
     self.remove_original = remove_original
     self.setup_widget()
예제 #20
0
 def __init__(self, 
              parent = None, 
              field_name = 'local_file', 
              directory = False, 
              save_as = False,
              file_filter = 'All files (*)',
              **kwargs):
     CustomEditor.__init__(self, parent)
     self.setObjectName( field_name )
     self._directory = directory
     self._save_as = save_as
     self._file_filter = file_filter
     self.setup_widget()
예제 #21
0
    def __init__(self,
                 parent=None,
                 editable=True,
                 address_type=None,
                 address_validator=default_address_validator,
                 field_name='virtual_address',
                 **kwargs):
        """
        :param address_type: limit the allowed address to be entered to be
            of a certain time, can be 'phone', 'fax', 'email', 'mobile', 'pager'.
            If set to None, all types are allowed.
            
        Upto now, the corrected address returned by the address validator is
        not yet taken into account.
        """
        CustomEditor.__init__(self, parent)
        self.setObjectName(field_name)
        self._address_type = address_type
        self._address_validator = address_validator
        self.layout = QtGui.QHBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.combo = QtGui.QComboBox()
        self.combo.addItems(camelot.types.VirtualAddress.virtual_address_types)
        self.combo.setEnabled(editable)
        if address_type:
            self.combo.setVisible(False)
        self.layout.addWidget(self.combo)
        self.editor = DecoratedLineEdit(self)
        self.editor.setEnabled(editable)
        self.editor.set_minimum_width(30)
        self.layout.addWidget(self.editor)
        self.setFocusProxy(self.editor)
        self.editable = editable
        nullIcon = Icon('tango/16x16/apps/internet-mail.png').getQIcon()
        self.label = QtGui.QToolButton()
        self.label.setIcon(nullIcon)
        self.label.setAutoRaise(True)
        self.label.setEnabled(False)
        self.label.setToolButtonStyle(Qt.ToolButtonIconOnly)
        self.label.setFocusPolicy(Qt.ClickFocus)
        self.label.clicked.connect(self.mail_click)
        self.label.hide()

        self.layout.addWidget(self.label)
        self.editor.editingFinished.connect(self.emit_editing_finished)
        self.editor.textEdited.connect(self.editorValueChanged)
        self.combo.currentIndexChanged.connect(self.comboIndexChanged)

        self.setLayout(self.layout)
        self.checkValue(self.editor.text())
예제 #22
0
    def __init__(self, 
                 parent = None, 
                 editable = True, 
                 address_type = None, 
                 address_validator = default_address_validator,
                 field_name = 'virtual_address',
                 **kwargs):
        """
        :param address_type: limit the allowed address to be entered to be
            of a certain time, can be 'phone', 'fax', 'email', 'mobile', 'pager'.
            If set to None, all types are allowed.
            
        Upto now, the corrected address returned by the address validator is
        not yet taken into account.
        """
        CustomEditor.__init__(self, parent)
        self.setObjectName( field_name )
        self._address_type = address_type
        self._address_validator = address_validator
        self.layout = QtGui.QHBoxLayout()
        self.layout.setContentsMargins( 0, 0, 0, 0)
        self.combo = QtGui.QComboBox()
        self.combo.addItems(camelot.types.VirtualAddress.virtual_address_types)
        self.combo.setEnabled(editable)
        if address_type:
            self.combo.setVisible(False)
        self.layout.addWidget(self.combo)
        self.editor = DecoratedLineEdit( self )
        self.editor.setEnabled(editable)
        self.editor.set_minimum_width( 30 )
        self.layout.addWidget(self.editor)
        self.setFocusProxy(self.editor)
        self.editable = editable
        nullIcon = Icon('tango/16x16/apps/internet-mail.png').getQIcon()
        self.label = QtGui.QToolButton()
        self.label.setIcon(nullIcon)
        self.label.setAutoRaise(True)
        self.label.setEnabled(False)
        self.label.setToolButtonStyle(Qt.ToolButtonIconOnly)
        self.label.setFocusPolicy(Qt.ClickFocus)
        self.label.clicked.connect( self.mail_click )
        self.label.hide()

        self.layout.addWidget(self.label)
        self.editor.editingFinished.connect(self.emit_editing_finished)
        self.editor.textEdited.connect(self.editorValueChanged)
        self.combo.currentIndexChanged.connect(self.comboIndexChanged)

        self.setLayout(self.layout)
        self.checkValue(self.editor.text())
예제 #23
0
    def __init__(self, parent, img='face-plain', editable=True, **kwargs):
        CustomEditor.__init__(self, parent)
        self.box = QtGui.QComboBox()
        self.box.setFrame(True)
        self.box.setEditable(False)
        self.allSmileys = []

        self.allSmileys.append('face-angel')
        self.allSmileys.append('face-crying')
        self.allSmileys.append('face-devilish')
        self.allSmileys.append('face-glasses')
        self.allSmileys.append('face-grin')
        self.allSmileys.append('face-kiss')
        self.allSmileys.append('face-monkey')
        self.allSmileys.append('face-plain')
        self.allSmileys.append('face-sad')
        self.allSmileys.append('face-smile')
        self.allSmileys.append('face-smile-big')
        self.allSmileys.append('face-surprise')
        self.allSmileys.append('face-wink')

        for i, value in enumerate(self.allSmileys):
            imgPath = 'tango/16x16/emotes/' + value + '.png'
            icon = Icon(imgPath).getQIcon()

            self.box.addItem(icon, '')
            self.box.setFixedHeight(self.get_height())

            if value == 'face-plain':
                self.box.setCurrentIndex(i)


        self.setFocusPolicy(Qt.StrongFocus)
        layout = QtGui.QHBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        self.img = img
        self.imgPath = 'tango/16x16/emotes/' + img + '.png'
        self.Icon = Icon(self.imgPath).getQIcon()
        self.setAutoFillBackground(True)
        #self.starCount = maximum
        if not editable:
            self.box.setEnabled(False)
        else:
            self.box.setEnabled(True)
        self.box.currentIndexChanged.connect(self.smiley_changed)

        layout.addWidget(self.box)
        layout.addStretch()
        self.setLayout(layout)
예제 #24
0
    def __init__(self, parent, img='face-plain', editable=True, **kwargs):
        CustomEditor.__init__(self, parent)
        self.box = QtGui.QComboBox()
        self.box.setFrame(True)
        self.box.setEditable(False)
        self.allSmileys = []

        self.allSmileys.append('face-angel')
        self.allSmileys.append('face-crying')
        self.allSmileys.append('face-devilish')
        self.allSmileys.append('face-glasses')
        self.allSmileys.append('face-grin')
        self.allSmileys.append('face-kiss')
        self.allSmileys.append('face-monkey')
        self.allSmileys.append('face-plain')
        self.allSmileys.append('face-sad')
        self.allSmileys.append('face-smile')
        self.allSmileys.append('face-smile-big')
        self.allSmileys.append('face-surprise')
        self.allSmileys.append('face-wink')

        for i, value in enumerate(self.allSmileys):
            imgPath = 'tango/16x16/emotes/' + value + '.png'
            icon = Icon(imgPath).getQIcon()

            self.box.addItem(icon, '')
            self.box.setFixedHeight(self.get_height())

            if value == 'face-plain':
                self.box.setCurrentIndex(i)

        self.setFocusPolicy(Qt.StrongFocus)
        layout = QtGui.QHBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        self.img = img
        self.imgPath = 'tango/16x16/emotes/' + img + '.png'
        self.Icon = Icon(self.imgPath).getQIcon()
        self.setAutoFillBackground(True)
        #self.starCount = maximum
        if not editable:
            self.box.setEnabled(False)
        else:
            self.box.setEnabled(True)
        self.box.currentIndexChanged.connect(self.smiley_changed)

        layout.addWidget(self.box)
        layout.addStretch()
        self.setLayout(layout)
예제 #25
0
    def __init__(self, parent, precision=2, reverse=False, neutral=False, option=None, field_name="float", **kwargs):
        CustomEditor.__init__(self, parent)
        self.setObjectName(field_name)
        action = QtGui.QAction(self)
        action.setShortcut(QtGui.QKeySequence(Qt.Key_F4))
        self.setFocusPolicy(Qt.StrongFocus)

        self.spinBox = CustomDoubleSpinBox(option, parent)
        self.spinBox.setDecimals(precision)
        self.spinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.spinBox.addAction(action)
        self.spinBox.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        self.arrow = QtGui.QLabel()
        self.arrow.setPixmap(self.go_up.getQPixmap())
        self.arrow.setFixedHeight(self.get_height())

        self.arrow.setAutoFillBackground(False)
        self.arrow.setMaximumWidth(19)

        self.calculatorButton = QtGui.QToolButton()
        self.calculatorButton.setIcon(self.calculator_icon.getQIcon())
        self.calculatorButton.setAutoRaise(True)
        self.calculatorButton.setFixedHeight(self.get_height())

        self.calculatorButton.clicked.connect(lambda: self.popupCalculator(self.spinBox.value()))
        action.triggered.connect(lambda: self.popupCalculator(self.spinBox.value()))
        self.spinBox.editingFinished.connect(self.spinbox_editing_finished)

        self.releaseKeyboard()

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addSpacing(3.5)
        layout.addWidget(self.arrow)
        layout.addWidget(self.spinBox)
        layout.addWidget(self.calculatorButton)
        self.reverse = reverse
        self.neutral = neutral
        self.setFocusProxy(self.spinBox)
        self.setLayout(layout)
        if not self.reverse:
            if not self.neutral:
                self.icons = {-1: self.go_down_red, 1: self.go_up, 0: self.zero}
            else:
                self.icons = {-1: self.go_down_blue, 1: self.go_up_blue, 0: self.zero}
        else:
            self.icons = {1: self.go_down_red, -1: self.go_up, 0: self.zero}
예제 #26
0
    def __init__( self,
                 admin = None,
                 parent = None,
                 create_inline = False,
                 vertical_header_clickable = True,
                 **kw ):
        """
    :param admin: the Admin interface for the objects on the one side of the
    relation

    :param create_inline: if False, then a new entity will be created within a
    new window, if True, it will be created inline

    :param vertical_header_clickable: True if the vertical header is clickable by the user, False if not.

    after creating the editor, set_value needs to be called to set the
    actual data to the editor
    """

        CustomEditor.__init__( self, parent )
        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins( 0, 0, 0, 0 )
        #
        # Setup table
        #
        from camelot.view.controls.tableview import AdminTableWidget
        # parent set by layout manager
        table = AdminTableWidget(admin, self)
        table.setObjectName('table')
        rowHeight = QtGui.QFontMetrics( self.font() ).height() + 5
        layout.setSizeConstraint( QtGui.QLayout.SetNoConstraint )
        self.setSizePolicy( QtGui.QSizePolicy.Expanding,
                            QtGui.QSizePolicy.Expanding )
        self.setMinimumHeight( rowHeight*5 )
        if vertical_header_clickable:
            table.verticalHeader().sectionClicked.connect(
                self.createFormForIndex
            )
        self.admin = admin
        self.create_inline = create_inline
        self.add_button = None
        self.copy_button = None
        self.delete_button = None
        layout.addWidget( table )
        self.setupButtons( layout, table )
        self.setLayout( layout )
        self.model = None
        self._new_message = None
예제 #27
0
    def __init__(self,
                 parent,
                 precision=2,
                 minimum=constants.camelot_minfloat,
                 maximum=constants.camelot_maxfloat,
                 calculator=True,
                 decimal=False,
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self._decimal = decimal
        self._calculator = calculator
        action = QtGui.QAction(self)
        action.setShortcut(Qt.Key_F3)
        self.setFocusPolicy(Qt.StrongFocus)
        self.precision = precision
        self.spinBox = CustomDoubleSpinBox(parent)

        self.spinBox.setRange(minimum, maximum)
        self.spinBox.setDecimals(precision)
        self.spinBox.setAlignment(Qt.AlignRight|Qt.AlignVCenter)

        self.spinBox.addAction(action)
        self.calculatorButton = QtGui.QToolButton()
        self.calculatorButton.setIcon( self.calculator_icon.getQIcon() )
        self.calculatorButton.setAutoRaise(True)
        self.calculatorButton.setFixedHeight(self.get_height())
        self.calculatorButton.setToolTip('Calculator F3')
        self.calculatorButton.setFocusPolicy(Qt.ClickFocus)

        self.calculatorButton.clicked.connect(
            lambda:self.popupCalculator(self.spinBox.value())
        )
        action.triggered.connect(
            lambda:self.popupCalculator(self.spinBox.value())
        )
        self.spinBox.editingFinished.connect( self.spinbox_editing_finished )

        self.releaseKeyboard()

        layout = QtGui.QHBoxLayout()
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.addWidget(self.spinBox)
        layout.addWidget(self.calculatorButton)
        self.setFocusProxy(self.spinBox)
        self.setLayout(layout)
예제 #28
0
    def __init__(self, parent = None,
                       minimum = camelot_minint,
                       maximum = camelot_maxint,
                       calculator = True,
                       option = None, 
                       field_name = 'integer',
                       **kwargs):
        
        CustomEditor.__init__(self, parent)
        self.setObjectName( field_name )
        action = QtGui.QAction(self)
        action.setShortcut( QtGui.QKeySequence( Qt.Key_F4 ) )
        self.setFocusPolicy(Qt.StrongFocus)
        
        self.spinBox = CustomDoubleSpinBox(option, parent)
        self.spinBox.setRange(minimum, maximum)
        self.spinBox.setDecimals(0)
        self.spinBox.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
        self.spinBox.addAction(action)
        self.spinBox.lineEdit().setText('')
        
        self.calculatorButton = QtGui.QToolButton()
        self.calculatorButton.setIcon(self.calculator_icon.getQIcon())
        self.calculatorButton.setAutoRaise(True)
        self.calculatorButton.setFocusPolicy(Qt.ClickFocus)
        self.calculatorButton.setFixedHeight(self.get_height())
        self.calculatorButton.clicked.connect(
            lambda:self.popupCalculator(self.spinBox.value())
        )
        action.triggered.connect(
            lambda:self.popupCalculator(self.spinBox.value())
        )
        self.spinBox.editingFinished.connect( self.spinbox_editing_finished )

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins( 0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.spinBox)
        layout.addWidget(self.calculatorButton)
        self.setFocusProxy(self.spinBox)
        self.setLayout(layout)
        self._nullable = True
        self._calculator = calculator
        
        self.option = option
예제 #29
0
    def __init__(self,
                 parent,
                 precision=2,
                 minimum=constants.camelot_minfloat,
                 maximum=constants.camelot_maxfloat,
                 calculator=True,
                 decimal=False,
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self._decimal = decimal
        self._calculator = calculator
        action = QtGui.QAction(self)
        action.setShortcut(Qt.Key_F3)
        self.setFocusPolicy(Qt.StrongFocus)
        self.precision = precision
        self.spinBox = CustomDoubleSpinBox(parent)

        self.spinBox.setRange(minimum, maximum)
        self.spinBox.setDecimals(precision)
        self.spinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        self.spinBox.addAction(action)
        self.calculatorButton = QtGui.QToolButton()
        self.calculatorButton.setIcon(self.calculator_icon.getQIcon())
        self.calculatorButton.setAutoRaise(True)
        self.calculatorButton.setFixedHeight(self.get_height())
        self.calculatorButton.setToolTip('Calculator F3')
        self.calculatorButton.setFocusPolicy(Qt.ClickFocus)

        self.calculatorButton.clicked.connect(
            lambda: self.popupCalculator(self.spinBox.value()))
        action.triggered.connect(
            lambda: self.popupCalculator(self.spinBox.value()))
        self.spinBox.editingFinished.connect(self.spinbox_editing_finished)

        self.releaseKeyboard()

        layout = QtGui.QHBoxLayout()
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.addWidget(self.spinBox)
        layout.addWidget(self.calculatorButton)
        self.setFocusProxy(self.spinBox)
        self.setLayout(layout)
예제 #30
0
 def __init__( self,
               admin = None,
               parent = None,
               create_inline = False,
               direction = 'onetomany',
               field_name = 'onetomany',
               **kw ):
     CustomEditor.__init__( self, parent )
     self.setObjectName( field_name )
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins( 0, 0, 0, 0 )
     #
     # Setup table
     #
     from camelot.view.controls.tableview import AdminTableWidget
     # parent set by layout manager
     table = AdminTableWidget(admin, self)
     table.setObjectName('table')
     rowHeight = QtGui.QFontMetrics( self.font() ).height() + 5
     layout.setSizeConstraint( QtGui.QLayout.SetNoConstraint )
     self.setSizePolicy( QtGui.QSizePolicy.Expanding,
                         QtGui.QSizePolicy.Expanding )
     self.setMinimumHeight( rowHeight*5 )
     table.verticalHeader().sectionClicked.connect(
         self.trigger_list_action
     )
     self.admin = admin
     self.direction = direction
     self.create_inline = create_inline
     layout.addWidget( table )
     self.setLayout( layout )
     self.model = None
     self._new_message = None
     self.gui_context = ListActionGuiContext()
     self.gui_context.view = self
     self.gui_context.admin = self.admin
     self.gui_context.item_view = table
     post( self.admin.get_related_toolbar_actions, 
           self.set_right_toolbar_actions,
           args = (Qt.RightToolBarArea, self.direction ) )
예제 #31
0
    def __init__(self,
                 parent=None,
                 storage=None,
                 remove_original=False,
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self.storage = storage

        # i'm a < 80 characters fanatic, i know :)
        self.new_icon = Icon('tango/16x16/actions/list-add.png').getQIcon()
        self.open_icon = Icon(
            'tango/16x16/actions/document-open.png').getQIcon()
        self.clear_icon = Icon(
            'tango/16x16/actions/edit-delete.png').getQIcon()
        self.save_as_icon = Icon(
            'tango/16x16/actions/document-save-as.png').getQIcon()
        self.document_pixmap = Icon(
            'tango/16x16/mimetypes/x-office-document.png').getQPixmap()

        self.value = None
        self.remove_original = remove_original
        self.setup_widget()
예제 #32
0
 def __init__(self,
              admin=None,
              parent=None,
              create_inline=False,
              direction='onetomany',
              field_name='onetomany',
              **kw):
     CustomEditor.__init__(self, parent)
     self.setObjectName(field_name)
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     #
     # Setup table
     #
     from camelot.view.controls.tableview import AdminTableWidget
     # parent set by layout manager
     table = AdminTableWidget(admin, self)
     table.setObjectName('table')
     rowHeight = QtGui.QFontMetrics(self.font()).height() + 5
     layout.setSizeConstraint(QtGui.QLayout.SetNoConstraint)
     self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                        QtGui.QSizePolicy.Expanding)
     self.setMinimumHeight(rowHeight * 5)
     table.verticalHeader().sectionClicked.connect(self.trigger_list_action)
     self.admin = admin
     self.direction = direction
     self.create_inline = create_inline
     layout.addWidget(table)
     self.setLayout(layout)
     self.model = None
     self._new_message = None
     self.gui_context = ListActionGuiContext()
     self.gui_context.view = self
     self.gui_context.admin = self.admin
     self.gui_context.item_view = table
     post(self.admin.get_related_toolbar_actions,
          self.set_right_toolbar_actions,
          args=(Qt.RightToolBarArea, self.direction))
예제 #33
0
 def __init__(self, parent=None, parts=['99','AA'], editable=True, **kwargs):
     CustomEditor.__init__(self, parent)
     self.parts = parts
     self.part_editors = []
     layout = QtGui.QHBoxLayout()
     layout.setMargin(0)
     layout.setSpacing(0)
     layout.setAlignment(Qt.AlignLeft)
     for i,part in enumerate(parts):
         part = re.sub('\W*', '', part)
         part_length = len(part)
         editor = PartEditor(part)
         editor.setFocusPolicy( Qt.StrongFocus )
         if i==0:
             self.setFocusProxy( editor )
         if not editable:
             editor.setEnabled(False)
         space_width = editor.fontMetrics().size(Qt.TextSingleLine, 'A').width()
         editor.setMaximumWidth(space_width*(part_length+1))
         self.part_editors.append(editor)
         layout.addWidget(editor)
         editor.editingFinished.connect(self.emit_editing_finished)
     self.setLayout(layout)
예제 #34
0
    def __init__(self,
                 parent,
                 maximum=5,
                 editable=True,
                 field_name='star',
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self.setObjectName(field_name)
        self.setFocusPolicy(Qt.StrongFocus)
        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        self.maximum = maximum
        self.buttons = []
        for i in range(self.maximum):
            button = QtGui.QToolButton(self)
            button.setIcon(self.no_star_icon.getQIcon())
            button.setFocusPolicy(Qt.ClickFocus)
            if editable:
                button.setAutoRaise(True)
            else:
                button.setAutoRaise(True)
                button.setDisabled(True)
            button.setFixedHeight(self.get_height())
            self.buttons.append(button)

        def createStarClick(i):
            return lambda: self.starClick(i + 1)

        for i in range(self.maximum):
            self.buttons[i].clicked.connect(createStarClick(i))

        for i in range(self.maximum):
            layout.addWidget(self.buttons[i])
        layout.addStretch()
        self.setLayout(layout)
    def __init__(self,
                 parent=None,
                 editable=True,
                 address_type=None,
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self._address_type = address_type
        self.layout = QtGui.QHBoxLayout()
        self.layout.setMargin(0)
        self.combo = QtGui.QComboBox()
        self.combo.addItems(camelot.types.VirtualAddress.virtual_address_types)
        self.combo.setEnabled(editable)
        if address_type:
            self.combo.setVisible(False)
        self.layout.addWidget(self.combo)
        self.editor = QtGui.QLineEdit()
        self.editor.setEnabled(editable)
        self.layout.addWidget(self.editor)
        self.setFocusProxy(self.editor)
        self.editable = editable
        nullIcon = Icon('tango/16x16/apps/internet-mail.png').getQIcon()
        self.label = QtGui.QToolButton()
        self.label.setIcon(nullIcon)
        self.label.setAutoFillBackground(False)
        self.label.setAutoRaise(True)
        self.label.setEnabled(False)
        self.label.setToolButtonStyle(Qt.ToolButtonIconOnly)

        self.layout.addWidget(self.label)
        self.editor.editingFinished.connect(self.emit_editing_finished)
        self.editor.textEdited.connect(self.editorValueChanged)
        self.combo.currentIndexChanged.connect(self.comboIndexChanged)

        self.setLayout(self.layout)
        self.setAutoFillBackground(True)
        self.checkValue(self.editor.text())
예제 #36
0
 def __init__(self, parent=None, parts=['99','AA'], editable=True, field_name='code', **kwargs):
     CustomEditor.__init__(self, parent)
     self.setObjectName( field_name )
     self.value = None
     self.parts = parts
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins( 0, 0, 0, 0)
     layout.setSpacing(0)
     layout.setAlignment(Qt.AlignLeft)
     for i, part in enumerate(parts):
         part = re.sub('\W*', '', part)
         part_length = len(part)
         editor = PartEditor(part, part_length, i==0, i==(len(parts)-1) )
         editor.setFocusPolicy( Qt.StrongFocus )
         if i==0:
             self.setFocusProxy( editor )
         if not editable:
             editor.setEnabled(False)
         space_width = editor.fontMetrics().size(Qt.TextSingleLine, 'A').width()
         editor.setMaximumWidth(space_width*(part_length+1))
         editor.setObjectName( 'part_%i'%i )
         layout.addWidget(editor)
         editor.editingFinished.connect(self.emit_editing_finished)
     self.setLayout(layout)
예제 #37
0
    def __init__(self,
                 parent,
                 precision=2,
                 reverse=False,
                 neutral=False,
                 **kwargs):
        CustomEditor.__init__(self, parent)
        action = QtGui.QAction(self)
        action.setShortcut(Qt.Key_F3)
        self.setFocusPolicy(Qt.StrongFocus)
        self.spinBox = CustomDoubleSpinBox(parent)

        self.spinBox.setDecimals(precision)
        self.spinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.spinBox.addAction(action)
        self.spinBox.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)
        self.arrow = QtGui.QLabel()
        self.arrow.setPixmap(
            Icon('tango/16x16/actions/go-up.png').getQPixmap())
        self.arrow.setFixedHeight(self.get_height())

        self.arrow.setAutoFillBackground(False)
        self.arrow.setMaximumWidth(19)

        self.calculatorButton = QtGui.QToolButton()
        icon = Icon('tango/16x16/apps/accessories-calculator.png').getQIcon()
        self.calculatorButton.setIcon(icon)
        self.calculatorButton.setAutoRaise(True)
        self.calculatorButton.setFixedHeight(self.get_height())

        self.calculatorButton.clicked.connect(
            lambda: self.popupCalculator(self.spinBox.value()))
        action.triggered.connect(
            lambda: self.popupCalculator(self.spinBox.value()))
        self.spinBox.editingFinished.connect(self.spinbox_editing_finished)

        self.releaseKeyboard()

        layout = QtGui.QHBoxLayout()
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.addSpacing(3.5)
        layout.addWidget(self.arrow)
        layout.addWidget(self.spinBox)
        layout.addWidget(self.calculatorButton)
        self.reverse = reverse
        self.neutral = neutral
        self.setFocusProxy(self.spinBox)
        self.setLayout(layout)
        if not self.reverse:
            if not self.neutral:
                self.icons = {
                    -1:
                    Icon('tango/16x16/actions/go-down-red.png').getQPixmap(),
                    1: Icon('tango/16x16/actions/go-up.png').getQPixmap(),
                    0: Icon('tango/16x16/actions/zero.png').getQPixmap()
                }
            else:
                self.icons = {
                    -1:
                    Icon('tango/16x16/actions/go-down-blue.png').getQPixmap(),
                    1: Icon('tango/16x16/actions/go-up-blue.png').getQPixmap(),
                    0: Icon('tango/16x16/actions/zero.png').getQPixmap()
                }
        else:
            self.icons = {
                1: Icon('tango/16x16/actions/go-down-red.png').getQPixmap(),
                -1: Icon('tango/16x16/actions/go-up.png').getQPixmap(),
                0: Icon('tango/16x16/actions/zero.png').getQPixmap()
            }
예제 #38
0
    def __init__(self, admin=None, parent=None, editable=True, **kwargs):
        """:param entity_admin : The Admin interface for the object on the one
        side of the relation
        """

        CustomEditor.__init__(self, parent)
        self.admin = admin
        self.entity_set = False
        self._editable = editable
        self._entity_representation = ''
        self.entity_instance_getter = None
        self._last_highlighted_entity_getter = None

        self.layout = QtGui.QHBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setMargin(0)

        # Search button
        self.search_button = QtGui.QToolButton()
        self.search_button.setAutoRaise(True)
        self.search_button.setFocusPolicy(Qt.ClickFocus)
        self.search_button.setFixedHeight(self.get_height())
        self.search_button.clicked.connect(self.searchButtonClicked)
        self.search_button.setIcon(
            Icon('tango/16x16/actions/edit-clear.png').getQIcon())
        self.search_button.setToolTip(unicode(_('clear')))

        # Open button
        self.open_button = QtGui.QToolButton()
        self.open_button.setAutoRaise(True)
        self.open_button.setFocusPolicy(Qt.ClickFocus)
        self.open_button.setFixedHeight(self.get_height())
        self.open_button.clicked.connect(self.openButtonClicked)
        self.open_button.setIcon(self.new_icon.getQIcon())
        self.open_button.setToolTip(unicode(_('new')))

        # Search input
        self.search_input = DecoratedLineEdit(self)
        self.search_input.set_background_text(_('Search...'))
        self.search_input.textEdited.connect(self.textEdited)
        # suppose garbage was entered, we need to refresh the content
        self.search_input.editingFinished.connect(
            self.search_input_editing_finished)
        self.setFocusProxy(self.search_input)

        # Search Completer
        self.completer = QtGui.QCompleter()
        self.completions_model = self.CompletionsModel(self.completer)
        self.completer.setModel(self.completions_model)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.completer.setCompletionMode(
            QtGui.QCompleter.UnfilteredPopupCompletion)
        #self.completer.activated.connect(self.completionActivated)
        #self.completer.highlighted.connect(self.completion_highlighted)
        self.completer.activated[QtCore.QModelIndex].connect(
            self.completionActivated)
        self.completer.highlighted[QtCore.QModelIndex].connect(
            self.completion_highlighted)
        self.search_input.setCompleter(self.completer)

        # Setup layout
        self.layout.addWidget(self.search_input)
        self.layout.addWidget(self.search_button)
        self.layout.addWidget(self.open_button)
        self.setLayout(self.layout)
예제 #39
0
    def __init__(self, admin=None, parent=None, editable=True, **kwargs):
        """:param entity_admin : The Admin interface for the object on the one
        side of the relation
        """

        CustomEditor.__init__(self, parent)
        self.admin = admin
        self.entity_set = False
        self._editable = editable
        self._entity_representation = ''
        self.entity_instance_getter = None
        self._last_highlighted_entity_getter = None

        self.layout = QtGui.QHBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setMargin(0)

        # Search button
        self.search_button = QtGui.QToolButton()
        self.search_button.setAutoRaise(True)
        self.search_button.setFocusPolicy(Qt.ClickFocus)
        self.search_button.setFixedHeight(self.get_height())
        self.search_button.clicked.connect(self.searchButtonClicked)
        self.search_button.setIcon(
            Icon('tango/16x16/actions/edit-clear.png').getQIcon()
        )
        self.search_button.setToolTip(unicode(_('clear')))

        # Open button
        self.open_button = QtGui.QToolButton()
        self.open_button.setAutoRaise(True)
        self.open_button.setFocusPolicy(Qt.ClickFocus)
        self.open_button.setFixedHeight(self.get_height())
        self.open_button.clicked.connect(self.openButtonClicked)
        self.open_button.setIcon( self.new_icon.getQIcon() )
        self.open_button.setToolTip(unicode(_('new')))

        # Search input
        self.search_input = DecoratedLineEdit(self)
        self.search_input.set_background_text(_('Search...'))
        self.search_input.textEdited.connect(self.textEdited)
        # suppose garbage was entered, we need to refresh the content
        self.search_input.editingFinished.connect( self.search_input_editing_finished )
        self.setFocusProxy(self.search_input)

        # Search Completer
        self.completer = QtGui.QCompleter()
        self.completions_model = self.CompletionsModel(self.completer)
        self.completer.setModel(self.completions_model)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.completer.setCompletionMode(
            QtGui.QCompleter.UnfilteredPopupCompletion
        )
        #self.completer.activated.connect(self.completionActivated)
        #self.completer.highlighted.connect(self.completion_highlighted)
        self.completer.activated[QtCore.QModelIndex].connect(self.completionActivated)
        self.completer.highlighted[QtCore.QModelIndex].connect(self.completion_highlighted)
        self.search_input.setCompleter(self.completer)

        # Setup layout
        self.layout.addWidget(self.search_input)
        self.layout.addWidget(self.search_button)
        self.layout.addWidget(self.open_button)
        self.setLayout(self.layout)
예제 #40
0
    def __init__(self,
                 parent,
                 precision=2,
                 reverse=False,
                 neutral=False,
                 option=None,
                 field_name='float',
                 **kwargs):
        CustomEditor.__init__(self, parent)
        self.setObjectName(field_name)
        action = QtGui.QAction(self)
        action.setShortcut(QtGui.QKeySequence(Qt.Key_F4))
        self.setFocusPolicy(Qt.StrongFocus)

        self.spinBox = CustomDoubleSpinBox(option, parent)
        self.spinBox.setDecimals(precision)
        self.spinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.spinBox.addAction(action)
        self.spinBox.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        self.arrow = QtGui.QLabel()
        self.arrow.setPixmap(self.go_up.getQPixmap())
        self.arrow.setFixedHeight(self.get_height())

        self.arrow.setAutoFillBackground(False)
        self.arrow.setMaximumWidth(19)

        self.calculatorButton = QtGui.QToolButton()
        self.calculatorButton.setIcon(self.calculator_icon.getQIcon())
        self.calculatorButton.setAutoRaise(True)
        self.calculatorButton.setFixedHeight(self.get_height())

        self.calculatorButton.clicked.connect(
            lambda: self.popupCalculator(self.spinBox.value()))
        action.triggered.connect(
            lambda: self.popupCalculator(self.spinBox.value()))
        self.spinBox.editingFinished.connect(self.spinbox_editing_finished)

        self.releaseKeyboard()

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addSpacing(3.5)
        layout.addWidget(self.arrow)
        layout.addWidget(self.spinBox)
        layout.addWidget(self.calculatorButton)
        self.reverse = reverse
        self.neutral = neutral
        self.setFocusProxy(self.spinBox)
        self.setLayout(layout)
        if not self.reverse:
            if not self.neutral:
                self.icons = {
                    -1: self.go_down_red,
                    1: self.go_up,
                    0: self.zero,
                }
            else:
                self.icons = {
                    -1: self.go_down_blue,
                    1: self.go_up_blue,
                    0: self.zero,
                }
        else:
            self.icons = {
                1: self.go_down_red,
                -1: self.go_up,
                0: self.zero,
            }