Beispiel #1
0
    def setvalue(self, value):
        strvalue = value
        if value in [None, "", NULL]:
            value = DateWidget.DEFAULTDATE
            self._is_valid = value.isValid()
        elif isinstance(value, basestring):
            value = QDateTime.fromString(strvalue, Qt.ISODate)
            if not value or (value and value.date().year() < 0):
                value = QDateTime.fromString(strvalue, Qt.SystemLocaleShortDate)

            self._is_valid = value.isValid()
            if not self._is_valid:
                raise ValueError("Unable to parse date string {}".format(strvalue))

        if isinstance(value, QDate):
            value = QDateTime(value)
            self._is_valid = value.isValid()

        if hasattr(self.datewidget, 'setDate'):
            self.datewidget.setDate(value.date())

        if hasattr(self.datewidget, 'setTime'):
            self.datewidget.setTime(value.time())

        self.set_date(value)
Beispiel #2
0
    def filter_score(self, index):
        """
            Returns the number of filters matching the given index.

            :param index:
                The index of the item that will be checked against the filters.
        """
        column = index.column()
        field_name = self.git_model.get_columns()[column]
        filters = self._filters

        if field_name in TIME_FIELDS:
            filters = self._filters
            timestamp, tz = self.git_model.data(index)
            _q_datetime = QDateTime()
            _q_datetime.setTime_t(timestamp)

            item_date = _q_datetime.date()
            item_weekday = item_date.dayOfWeek()
            item_time = _q_datetime.time()

            date_time_filters = ("afterWeekday", "beforeWeekday",
                                 "beforeDate", "afterDate",
                                 "beforeHour", "afterHour")
            has_date_time_filter = False
            for model_filter in filters:
                if model_filter in date_time_filters:
                    has_date_time_filter = True

            if not has_date_time_filter:
                return 0
            else:
                return self.date_match(item_date) + \
                       self.weekday_match(item_weekday) + \
                       self.time_match(item_time)

        elif field_name in ACTOR_FIELDS:
            if "nameEmail" in filters:
                regexp = filters["nameEmail"]
                value = self.git_model.data(index)
                if regexp.isValid() and regexp.indexIn(value) != -1:
                    return 1

        elif field_name in TEXT_FIELDS:
            if "message" in filters:
                regexp = filters["message"]
                commit_message = self.git_model.data(index)
                if regexp.isValid() and regexp.indexIn(commit_message) != -1:
                    return 1

        elif field_name == "hexsha":
            if "localOnly" in filters:
                commits = self.git_model.get_commits()
                commit = commits[index.row()]
                if not self.git_model.is_commit_pushed(commit):
                    return 1

        return 0
Beispiel #3
0
    def setvalue(self, value):
        if value is None:
            value = DateWidget.DEFAULTDATE
        elif isinstance(value, basestring):
            value = QDateTime.fromString(value, Qt.ISODate)

        if isinstance(value, QDate):
            value = QDateTime(value)

        if hasattr(self.datewidget, 'setDate'):
            self.datewidget.setDate(value.date())

        if hasattr(self.datewidget, 'setTime'):
            self.datewidget.setTime(value.time())
Beispiel #4
0
    def setvalue(self, value):
        if value is None:
            value = DateWidget.DEFAULTDATE
        elif isinstance(value, basestring):
            value = QDateTime.fromString(value, Qt.ISODate)

        if isinstance(value, QDate):
            value = QDateTime(value)

        if hasattr(self.datewidget, "setDate"):
            self.datewidget.setDate(value.date())

        if hasattr(self.datewidget, "setTime"):
            self.datewidget.setTime(value.time())
Beispiel #5
0
    def setvalue(self, value):
        strvalue = value
        if value is None:
            value = DateWidget.DEFAULTDATE
        elif isinstance(value, basestring):
            value = QDateTime.fromString(strvalue, Qt.ISODate)
            if not value or (value and value.date().year() < 0):
                value = QDateTime.fromString(strvalue, Qt.SystemLocaleShortDate)

        if isinstance(value, QDate):
            value = QDateTime(value)

        if hasattr(self.datewidget, 'setDate'):
            self.datewidget.setDate(value.date())

        if hasattr(self.datewidget, 'setTime'):
            self.datewidget.setTime(value.time())

        self.set_date(value)
Beispiel #6
0
    def setvalue(self, value):
        strvalue = value
        if value is None:
            value = DateWidget.DEFAULTDATE
        elif isinstance(value, basestring):
            value = QDateTime.fromString(strvalue, Qt.ISODate)
            if not value or (value and value.date().year() < 0):
                value = QDateTime.fromString(strvalue,
                                             Qt.SystemLocaleShortDate)

        if isinstance(value, QDate):
            value = QDateTime(value)

        if hasattr(self.datewidget, 'setDate'):
            self.datewidget.setDate(value.date())

        if hasattr(self.datewidget, 'setTime'):
            self.datewidget.setTime(value.time())

        self.set_date(value)