Exemple #1
0
 def __insert_reminder_events(self, record: QSqlRecord):
     index = record.value(0)
     start_date = record.value(
         Resources.EventManager_Column_StartDate_Index)
     count = record.value(Resources.EventManager_Column_Count_Index)
     Tools.write_verbose_class_method_name(
         self, EventManager.__insert_reminder_events, "event_id",
         str(index))
     self.__insert_missing_reminder_events(index, start_date, count)
            def callback(record: QSqlRecord, pattern: typing.Any):
                if custom_match:
                    return custom_match(record, pattern)

                value = record.value(field)
                regex = '.*?{0}.*'.format(pattern)
                match = re.search(pattern, value or '', flags=re.IGNORECASE)
                return match is not None
Exemple #3
0
    def __update_active(self, old_record: QSqlRecord, new_record: QSqlRecord):
        new_value = bool(
            new_record.value(Resources.EventManager_Column_IsActive_Index))
        if bool(old_record.value(
                Resources.EventManager_Column_IsActive_Index)) == new_value:
            return

        index = old_record.value(0)
        Tools.write_verbose_class_method_name(self,
                                              EventManager.__update_active,
                                              "event_id", str(index))

        if new_value is False:  # if change to inactive
            sql = Resources.Manager_DELETE_ReminderEvent % index
            self.__db.exec(sql)
        else:  # if change to active
            self.__insert_reminder_events(new_record)
    def data(self, index, rol):
        if rol < Qt.UserRole:
            return QSqlTableModel.data(self, index, rol)

        sql_kayit = QSqlRecord()
        sql_kayit = self.record(index.row())

        return sql_kayit.value(rol - Qt.UserRole)
Exemple #5
0
 def __before_update(self, row: int, record: QSqlRecord):
     del row
     index = record.value(0)
     query = self.__db.exec(Resources.EventManager_SELECT_Event % index)
     query.next()
     old_record = query.record()
     self.__update_active(old_record, record)
     self.__update_count(old_record, record)
     Tools.write_verbose_class_method_name(self,
                                           EventManager.__before_update,
                                           "updated", str(index))
Exemple #6
0
 def __before_insert(self, record: QSqlRecord):
     index = record.value(0)
     self.__insert_reminder_events(record)
     self.__added_items.remove(index)
     Tools.write_verbose_class_method_name(self,
                                           EventManager.__before_insert,
                                           "added_items.remove", str(index))
     Tools.write_verbose_class_method_name(self,
                                           EventManager.__before_insert,
                                           "added_items.remained",
                                           str(self.__added_items))
Exemple #7
0
    def __update_count(self, old_record: QSqlRecord, new_record: QSqlRecord):
        new_value = new_record.value(Resources.EventManager_Column_Count_Index)
        old_value = old_record.value(Resources.EventManager_Column_Count_Index)
        if new_value == old_value:
            return

        index = new_record.value(0)
        Tools.write_verbose_class_method_name(self,
                                              EventManager.__update_count,
                                              "event_id", str(index))

        if new_value > old_value:  # we need to add missing records
            start_date = new_record.value(
                Resources.EventManager_Column_StartDate_Index)
            count = new_value - old_value
            self.__insert_missing_reminder_events(index, start_date, count)
        else:  # we need to delete redundant records
            count = old_value - new_value
            sql = Resources.EventManager_DELETE_Newest_ReminderEvents % (index,
                                                                         count)
            self.__db.exec(sql)
Exemple #8
0
    def __add_value_to_row(self, record: QSqlRecord, row: int, column: int, value_name: str, is_editable: bool = False, is_selectable: bool = True, is_enable: bool = True):
        item = QTableWidgetItem(str(record.value(value_name)))
        flags = item.flags()

        if is_editable:
            flags = flags | Qt.ItemIsEditable
        else:
            flags = flags & ~Qt.ItemIsEditable

        if is_selectable:
            flags = flags | Qt.ItemIsSelectable
        else:
            flags = flags & ~Qt.ItemIsSelectable

        if is_enable:
            flags = flags | Qt.ItemIsEnabled
        else:
            flags = flags & ~Qt.ItemIsEnabled

        item.setFlags(flags)
        self.__view.setItem(row, column, item)
Exemple #9
0
 def __add_button_to_row(self, record: QSqlRecord, row: int, column: int):
     button = QPushButton(Resources.ReminderEventTab_BUTTON_NAME_Done)
     button.setProperty(Resources.ReminderEventTab_Property_Id, QVariant(record.value(0)))
     button.setProperty(Resources.ReminderEventTab_Property_EventId, QVariant(record.value(Resources.ReminderEventTab_Column_EventId)))
     button.clicked.connect(self.__button_clicked)
     self.__view.setCellWidget(row, column, button)