def update_checked_videos_state(self, item: QTableWidgetItem):
     video_index = item.row()
     if self.checking_row_updates:
         self.checking_row_updates = False
         self.update_selected_row(row_index=video_index)
         if item.checkState() == Qt.Unchecked:
             self.update_row_text_color(row_index=video_index,
                                        color_string="#787878")
             self.update_unchecked_video_signal.emit(video_index)
         elif item.checkState() == Qt.Checked:
             self.update_row_text_color(row_index=video_index,
                                        color_string="#000000")
             self.update_checked_video_signal.emit(video_index)
         self.checking_row_updates = True
 def update_checked_attachments_state(self, item: QTableWidgetItem):
     attachment_index = item.row()
     if self.checking_row_updates:
         self.checking_row_updates = False
         self.update_selected_row(row_index=attachment_index)
         if attachment_index < len(
                 GlobalSetting.ATTACHMENT_FILES_CHECKING_LIST):
             if item.checkState() == Qt.Unchecked:
                 GlobalSetting.ATTACHMENT_FILES_CHECKING_LIST[
                     attachment_index] = False
                 self.update_row_text_color(row_index=attachment_index,
                                            color_string="#787878")
                 self.update_unchecked_attachment_signal.emit(
                     GlobalSetting.
                     ATTACHMENT_FILES_ABSOLUTE_PATH_LIST[attachment_index])
             elif item.checkState() == Qt.Checked:
                 GlobalSetting.ATTACHMENT_FILES_CHECKING_LIST[
                     attachment_index] = True
                 self.update_row_text_color(row_index=attachment_index,
                                            color_string="#000000")
                 self.update_checked_attachment_signal.emit(
                     GlobalSetting.
                     ATTACHMENT_FILES_ABSOLUTE_PATH_LIST[attachment_index])
         self.checking_row_updates = True
Beispiel #3
0
    def build_analysis(self) -> None:
        """"""
        columns = ['Data analisys',
                   'PID',
                   'CPU%',
                   'Memory',
                   'Status',
                   ]

        start_index = self.parent_frame.tableWidget_anlaysis.rowCount() - 1
        if self.parent_frame.tableWidget_anlaysis.rowCount() == 0:
            self.parent_frame.tableWidget_anlaysis.clear()
            self.parent_frame.tableWidget_anlaysis.setRowCount(0)
            self.parent_frame.tableWidget_anlaysis.setColumnCount(len(columns))
            self.parent_frame.tableWidget_anlaysis.setHorizontalHeaderLabels(
                columns)
            already_items = []

            to_remove = []
            to_add = [self.parent_frame.listWidget_projects_analysis.item(i).text(
            ) for i in range(self.parent_frame.listWidget_projects_analysis.count())]

        else:
            # start_index = 0
            already_items = [self.parent_frame.tableWidget_anlaysis.item(
                i, 0).text() for i in range(self.parent_frame.tableWidget_anlaysis.rowCount())]
            new_ones = [self.parent_frame.listWidget_projects_analysis.item(
                i).text() for i in range(self.parent_frame.listWidget_projects_analysis.count())]

            to_remove = set(already_items) - set(new_ones)
            to_add = set(new_ones) - set(already_items)

        for i, script_name in enumerate(to_add):

            if script_name.startswith('_'):
                continue

            if script_name in already_items:
                continue

            # if item.text().startswith('Tutorial |'):
                # continue

            self.parent_frame.tableWidget_anlaysis.insertRow(start_index + i)
            for j in range(len(columns)):

                if j == 0:
                    item = QTableWidgetItem(script_name)
                    item.setCheckState(Qt.Unchecked)
                    item.is_running = False
                else:
                    item = QTableWidgetItem()

                if 0 < j < 4:
                    item.setTextAlignment(Qt.AlignCenter)

                item.setFlags(item.flags() & ~Qt.ItemIsEditable
                              & ~Qt.ItemIsSelectable)
                self.parent_frame.tableWidget_anlaysis.setItem(
                    start_index + i, j, item)

                self.parent_frame.tableWidget_anlaysis.cellWidget(
                    start_index + i, j)

        for script_name in to_remove:
            for i in range(self.parent_frame.tableWidget_anlaysis.rowCount()):
                item = self.parent_frame.tableWidget_anlaysis.item(i, 0)
                if item.text() == script_name:
                    if not item.checkState() == Qt.Checked:
                        self.parent_frame.tableWidget_anlaysis.removeRow(i)
                    else:
                        item.to_remove = True
                    break

        self.parent_frame.tableWidget_anlaysis.sortByColumn(0)