Exemplo n.º 1
0
 def init_value_box(self):
     self.value_box.setEnabled(True)
     self.value_box.setText('')
     self.value_box.setInputMask('')
     self.value_box.setValidator(None)
     col = self.current_col
     if not col:
         return
     action = self.current_action
     if not action:
         return
     m = self.fm[col]
     dt = m['datatype']
     tt = ''
     if col == 'identifiers':
         tt = _('Enter either an identifier type or an '
                'identifier type and value of the form identifier:value')
     elif col == 'languages':
         tt = _('Enter a 3 letter ISO language code, like fra for French'
                ' or deu for German or eng for English. You can also use'
                ' the full language name, in which case calibre will try to'
                ' automatically convert it to the language code.')
     elif dt in ('int', 'float', 'rating'):
         tt = _('Enter a number')
         v = QIntValidator if dt == 'int' else QDoubleValidator
         self.value_box.setValidator(v(self.value_box))
     elif dt == 'datetime':
         if action == 'count_days':
             self.value_box.setValidator(QIntValidator(self.value_box))
             tt = _(
                 'Enter the maximum days old the item can be. Zero is today. '
                 'Dates in the future always match')
         elif action == 'older count days':
             self.value_box.setValidator(QIntValidator(self.value_box))
             tt = _(
                 'Enter the minimum days old the item can be. Zero is today. '
                 'Dates in the future never match')
         elif action == 'older future days':
             self.value_box.setValidator(QIntValidator(self.value_box))
             tt = _('Enter the maximum days in the future the item can be. '
                    'Zero is today. Dates in the past always match')
         elif action == 'newer future days':
             self.value_box.setValidator(QIntValidator(self.value_box))
             tt = _('Enter the minimum days in the future the item can be. '
                    'Zero is today. Dates in the past never match')
         else:
             self.value_box.setInputMask('9999-99-99')
             tt = _('Enter a date in the format YYYY-MM-DD')
     else:
         tt = _('Enter a string.')
         if 'pattern' in action:
             tt = _('Enter a regular expression')
         elif m.get('is_multiple', False):
             tt += '\n' + _(
                 'You can match multiple values by separating'
                 ' them with %s') % m['is_multiple']['ui_to_list']
     self.value_box.setToolTip(tt)
     if action in ('is set', 'is not set', 'is true', 'is false',
                   'is undefined'):
         self.value_box.setEnabled(False)
Exemplo n.º 2
0
 def __init__(self, *args):
     QWidget.__init__(self, *args)
     lo = QHBoxLayout(self)
     lo.setContentsMargins(0, 0, 0, 0)
     lo.setSpacing(5)
     # type selector
     self.wtypesel = QComboBox(self)
     for i, tp in enumerate(self.ValueTypes):
         self.wtypesel.addItem(tp.__name__)
     QObject.connect(self.wtypesel, SIGNAL("activated(int)"),
                     self._selectTypeNum)
     typesel_lab = QLabel("&Type:", self)
     typesel_lab.setBuddy(self.wtypesel)
     lo.addWidget(typesel_lab, 0)
     lo.addWidget(self.wtypesel, 0)
     self.wvalue = QLineEdit(self)
     self.wvalue_lab = QLabel("&Value:", self)
     self.wvalue_lab.setBuddy(self.wvalue)
     self.wbool = QComboBox(self)
     self.wbool.addItems(["false", "true"])
     self.wbool.setCurrentIndex(1)
     lo.addWidget(self.wvalue_lab, 0)
     lo.addWidget(self.wvalue, 1)
     lo.addWidget(self.wbool, 1)
     self.wvalue.hide()
     # make input validators
     self._validators = {
         int: QIntValidator(self),
         float: QDoubleValidator(self)
     }
     # select bool type initially
     self._selectTypeNum(0)
    def __init__(self, rddtDataExtractor, notifyImgurAPI):
        """
        The Dialog that handles changing settings for how the program operates
        :type rddtDataExtractor: RedditDataExtractor.redditDataExtractor.RedditDataExtractor
        :type notifyImgurAPI: function
        """
        QDialog.__init__(self)

        # Set up the user interface from Designer.
        self.setupUi(self)

        self.userLists = rddtDataExtractor.userLists
        self.subredditLists = rddtDataExtractor.subredditLists
        self.currentUserListName = rddtDataExtractor.defaultUserListName
        self.currentSubredditListName = rddtDataExtractor.defaultSubredditListName
        self.avoidDuplicates = rddtDataExtractor.avoidDuplicates
        self.getExternalContent = rddtDataExtractor.getExternalContent
        self.getCommentExternalContent = rddtDataExtractor.getCommentExternalContent
        self.getSelftextExternalContent = rddtDataExtractor.getSelftextExternalContent
        self.getSubmissionContent = rddtDataExtractor.getSubmissionContent
        self.subSort = rddtDataExtractor.subSort
        self.subLimit = rddtDataExtractor.subLimit
        self.operMap = rddtDataExtractor.operMap
        self.validOperForPropMap = rddtDataExtractor.validOperForPropMap
        self.connectMap = rddtDataExtractor.connectMap
        self.filterExternalContent = rddtDataExtractor.filterExternalContent
        self.filterSubmissionContent = rddtDataExtractor.filterSubmissionContent
        self.restrictDownloadsByCreationDate = rddtDataExtractor.restrictDownloadsByCreationDate
        self.showImgurAPINotification = rddtDataExtractor.showImgurAPINotification
        self.avoidVideos = rddtDataExtractor.avoidVideos
        self.getAuthorsCommentsOnly = rddtDataExtractor.getAuthorsCommentsOnly
        self.notifyImgurAPI = notifyImgurAPI
        self.validator = QIntValidator(1, 1000)
        self.filtTableTypeCol = 0
        self.filtTablePropCol = 1
        self.filtTableOperCol = 2
        self.filtTableValCol = 3
        self.filtTableConnectCol = 4

        self.defaultUserListComboBox.activated.connect(self.chooseNewUserList)
        self.defaultSubredditListComboBox.activated.connect(
            self.chooseNewSubredditList)

        self.avoidDuplCheckBox.clicked.connect(lambda: self.changeCheckBox(
            self.avoidDuplCheckBox, 'avoidDuplicates'))
        self.getExternalContentCheckBox.clicked.connect(
            lambda: self.changeCheckBox(self.getExternalContentCheckBox,
                                        'getExternalContent'))
        self.getCommentExternalContentCheckBox.clicked.connect(
            lambda: self.changeCheckBox(self.getCommentExternalContentCheckBox,
                                        'getCommentExternalContent'))
        self.getSelftextExternalContentCheckBox.clicked.connect(
            lambda: self.changeCheckBox(
                self.getSelftextExternalContentCheckBox,
                'getSelftextExternalContent'))
        self.getSubmissionContentCheckBox.clicked.connect(
            lambda: self.changeCheckBox(self.getSubmissionContentCheckBox,
                                        'getSubmissionContent'))
        self.showImgurAPINotificationCheckBox.clicked.connect(
            lambda: self.changeCheckBox(self.showImgurAPINotificationCheckBox,
                                        'showImgurAPINotification'))
        self.avoidVideosCheckBox.clicked.connect(lambda: self.changeCheckBox(
            self.avoidVideosCheckBox, 'avoidVideos'))
        self.getAuthorsCommentsOnlyCheckBox.clicked.connect(
            lambda: self.changeCheckBox(self.getAuthorsCommentsOnlyCheckBox,
                                        'getAuthorsCommentsOnly'))

        self.resetClientIdCheckBox.clicked.connect(self.notifyImgurAPI)

        self.hotBtn.clicked.connect(lambda: self.changeSubSort("hot"))
        self.newBtn.clicked.connect(lambda: self.changeSubSort("new"))
        self.risingBtn.clicked.connect(lambda: self.changeSubSort("rising"))
        self.controversialBtn.clicked.connect(
            lambda: self.changeSubSort("controversial"))
        self.topBtn.clicked.connect(lambda: self.changeSubSort("top"))

        self.subLimitTextEdit.textChanged.connect(self.setSubLimit)
        self.subLimitTextEdit.setValidator(self.validator)
        self.subLimitTextEdit.setText(
            str(self.subLimit) if self.subLimit is not None else "1000")

        self.filterTable.cellPressed.connect(self.addFilter)
        self.constructFilterTable(rddtDataExtractor.submissionFilts,
                                  rddtDataExtractor.commentFilts,
                                  rddtDataExtractor.connector,
                                  rddtDataExtractor.operMap,
                                  rddtDataExtractor.connectMap)
        self.filterExternalContentCheckBox.clicked.connect(
            lambda: self.changeCheckBox(self.filterExternalContentCheckBox,
                                        'filterExternalContent'))
        self.filterSubmissionContentCheckBox.clicked.connect(
            lambda: self.changeCheckBox(self.filterSubmissionContentCheckBox,
                                        'filterSubmissionContent'))

        self.restrictDownloadsByCreationDateCheckBox.clicked.connect(
            lambda: self.changeCheckBox(
                self.restrictDownloadsByCreationDateCheckBox,
                'restrictDownloadsByCreationDate'))

        self.initSettings()