Beispiel #1
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()
Beispiel #2
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)
    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())
Beispiel #4
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)
Beispiel #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)
    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)
    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)
Beispiel #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)
Beispiel #9
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)
Beispiel #10
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)
Beispiel #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)
Beispiel #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)
Beispiel #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()
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #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()
Beispiel #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()
Beispiel #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()
Beispiel #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())
    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())
Beispiel #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)
Beispiel #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)
Beispiel #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}
    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
Beispiel #27
0
 def get_value(self):
     color = self.getColor()
     if color:
         value = (color.red(), color.green(), color.blue(), color.alpha())
     else:
         value = None
     return CustomEditor.get_value(self) or value
Beispiel #28
0
 def get_value(self):
     """:return: a function that returns the selected entity or ValueLoading
     or None"""
     value = CustomEditor.get_value(self)
     if not value:
         value = self.entity_instance_getter
     return value
Beispiel #29
0
 def set_value(self, value):
     """:param value: either ValueLoading, or a function that returns None
     or the entity to be shown in the editor"""
     self._last_highlighted_entity_getter = None
     value = CustomEditor.set_value(self, value)
     if value:
         self.setEntity(value, propagate = False)
Beispiel #30
0
 def get_value(self):
     """:return: a function that returns the selected entity or ValueLoading
     or None"""
     value = CustomEditor.get_value(self)
     if not value:
         value = self.entity_instance_getter
     return value
Beispiel #31
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value is None:
         self.spinBox.lineEdit().setText('')
     else:
         value = str(value).replace(',', '.')
         self.spinBox.setValue(eval(value))
Beispiel #32
0
 def get_value(self):
     color = self.getColor()
     if color:
         value = (color.red(), color.green(), color.blue(), color.alpha())
     else:
         value = None
     return CustomEditor.get_value(self) or value
Beispiel #33
0
 def set_value(self, value):
     """:param value: either ValueLoading, or a function that returns None
     or the entity to be shown in the editor"""
     self._last_highlighted_entity_getter = None
     value = CustomEditor.set_value(self, value)
     if value:
         self.setEntity(value, propagate=False)
Beispiel #34
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value) or 0
     self.stars = int(value)
     for i in range(self.maximum):
         if i + 1 <= self.stars:
             self.buttons[i].setIcon(self.star_icon.getQIcon())
         else:
             self.buttons[i].setIcon(self.no_star_icon.getQIcon())
Beispiel #35
0
    def get_value(self):
        from xml.dom import minidom

        tree = minidom.parseString(unicode(self.textedit.toHtml()).encode("utf-8"))
        value = u"".join(
            [node.toxml() for node in tree.getElementsByTagName("html")[0].getElementsByTagName("body")[0].childNodes]
        )
        return CustomEditor.get_value(self) or value
Beispiel #36
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value) or 0
     self.stars = int(value)
     for i in range(self.starCount):
         if i+1 <= self.stars:
             self.buttons[i].setIcon(self.star_icon.getQIcon())
         else:
             self.buttons[i].setIcon(self.no_star_icon.getQIcon())
Beispiel #37
0
    def set_value(self, value):
        value = CustomEditor.set_value(self, value) or 'face-plain'
        self.img = value
        #self.imgPath = 'tango/16x16/emotes/' + self.img + '.png'

        for i, smiley in enumerate(self.allSmileys):
            if smiley == self.img:
                self.box.setCurrentIndex(i)
Beispiel #38
0
    def get_value(self):
        imgIndex = self.box.currentIndex()

        for i, emot in enumerate(self.allSmileys):
            if imgIndex == i:
                imgName = emot

        return CustomEditor.get_value(self) or imgName
 def set_value( self, model ):
     model = CustomEditor.set_value( self, model )
     table = self.findChild(QtGui.QWidget, 'table')
     if table and model and model != self.model:
         self.model = model
         table.setModel( model )
         register.register( self.model, table )
         post( model._extend_cache, self.update_delegates )
Beispiel #40
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         color = QtGui.QColor()
         color.setRgb(*value)
         self.setColor(color)
     else:
         self.setColor(value)
Beispiel #41
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         self.filename.setText(value)
     else:
         self.filename.setText('')
     self.valueChanged.emit()
     return value
Beispiel #42
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         self.spinBox.setValue(float(value))
     elif value == None:
         self.spinBox.lineEdit().setText('')
     else:
         self.spinBox.setValue(0.0)
Beispiel #43
0
    def get_value(self):
        imgIndex = self.box.currentIndex()

        for i, emot in enumerate(self.allSmileys):
            if imgIndex == i:
                imgName = emot

        return CustomEditor.get_value(self) or imgName
Beispiel #44
0
    def set_value(self, value):
        value = CustomEditor.set_value(self, value) or 'face-plain'
        self.img = value
        #self.imgPath = 'tango/16x16/emotes/' + self.img + '.png'

        for i, smiley in enumerate(self.allSmileys):
            if smiley == self.img:
                self.box.setCurrentIndex(i)
Beispiel #45
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         color = QtGui.QColor()
         color.setRgb(*value)
         self.setColor(color)
     else:
         self.setColor(value)
Beispiel #46
0
     return CustomEditor.get_value(self) or value
 
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         self.dateedit.set_value(value.date())
         self.timeedit.lineEdit().setText('%02i:%02i'%(value.hour, value.minute))
     else:
Beispiel #47
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         self.filename.setText( value )
     else:
         self.filename.setText( '' )
     self.valueChanged.emit()
     return value
Beispiel #48
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)
Beispiel #49
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         self.spinBox.setValue( float(value) )
     elif value == None:
         self.spinBox.lineEdit().setText('')
     else:
         self.spinBox.setValue(0.0)
Beispiel #50
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
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         self.dateedit.set_value(value.date())
         self.timeedit.lineEdit().setText('%02i:%02i' %
                                          (value.hour, value.minute))
     else:
         self.dateedit.set_value(None)
         self.timeedit.lineEdit().setText('--:--')
Beispiel #52
0
 def get_value(self):
     from xml.dom import minidom
     tree = minidom.parseString(
         unicode(self.textedit.toHtml()).encode('utf-8'))
     value = u''.join([
         node.toxml() for node in tree.getElementsByTagName('html')
         [0].getElementsByTagName('body')[0].childNodes
     ])
     return CustomEditor.get_value(self) or value
Beispiel #53
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value != None:
         if unicode(self.textedit.toHtml()) != value:
             self.update_alignment()
             self.textedit.setHtml(value)
             self.update_color()
     else:
         self.textedit.clear()
Beispiel #54
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)
Beispiel #55
0
 def set_value(self, value):
     value = CustomEditor.set_value(self, value)
     if value:
         old_value = self.get_value()
         if value != old_value:
             for part_editor, part in zip(self.part_editors, value):
                 part_editor.setText(unicode(part))
     else:
         for part_editor in self.part_editors:
             part_editor.setText(u'')