Beispiel #1
0
 def create_current_item(self, flags):
     if self.active_stack.index() == 0:
         txt = _('  0: Geladener Zustand des Dokuments')
     else:
         txt = _('  0: Aktueller Zustand des Dokuments')
     current_item = QListWidgetItem(txt)
     current_item.setForeground(self.fg_black)
     current_item.setBackground(self.bg_grey)
     current_item.setFlags(flags)
     current_item.setIcon(IconRsc.get_icon('options'))
     return current_item
Beispiel #2
0
    def _add_list_item(self, item_data: ResultItemData) -> None:
        new_item = QListWidgetItem(item_data.title)
        new_item.setData(Qt.UserRole, item_data.glob_id)

        if item_data.rgb is not None:
            color = QColor(*item_data.rgb)
            brush = QBrush(color)
            new_item.setForeground(brush)

        icon = self._data_icons.get(item_data.category.lower(), None)
        if icon is not None:
            new_item.setIcon(icon)

        self.ui.search_result_list.addItem(new_item)
Beispiel #3
0
 def Write(self, files):
     self.clear()
     for f in files:
         item = QListWidgetItem(f, self)
         if self._folder is None:
             item.setForeground(QBrush(Qt.red))
             continue
         filename = os.path.join(self._folder, f)
         if not os.path.isfile(filename):
             item.setForeground(QBrush(Qt.red))
             continue
         item.setIcon(icons.FileIcon(filename))
         item.setData(Qt.UserRole, filename)
     self.sortItems()
Beispiel #4
0
    def color_changer(self, item: QtWidgets.QListWidgetItem):
        """
        Change the background color of the item in the list, and its foreground color depending on the background color
        :param item: A list widget item, the one that is currently selected
        """

        item.setBackgroundColor(QtGui.QColor(*item.note.color))
        if item.note.color not in [(255, 255, 255), [255, 255, 255],
                                   (202, 207, 210), [202, 207, 210]]:
            item.setForeground(QtGui.QColor("#FFFFFF"))
        else:
            item.setForeground(QtGui.QColor(*(0, 0, 0)))

        item.set_background_color()
Beispiel #5
0
    def create_history_item(self, c: int, txt: str, icon, redo_idx):
        num = c - redo_idx
        if num >= 0:
            num += 1

        item = QListWidgetItem(f'{txt} [{num: 3d}]', self.viewList)
        item.setData(Qt.UserRole, c)
        item.setFlags(self.enabled_flags)
        item.setIcon(icon)

        if num > 0:
            item.setForeground(self.fg_grey)
            item.setFont(FontRsc.italic)

        return item
Beispiel #6
0
    def load_files(self, progress_callback):
        """
        Traverse folder to find .nif files
        """
        ignored_files = 0
        for root, dirs, files in os.walk(self.source_folder):
            for file in files:
                path = root + "/" + file
                if file.endswith(
                        ".nif"
                ) and path not in self.nif_files and path not in self.ignored_nif_files:
                    stream = open(path, "rb")
                    data = NifFormat.Data()
                    success = False
                    add_to_ignored_list = False
                    try:
                        data.inspect(stream)
                        if "NiNode".encode(
                                'ascii') == data.header.block_types[0]:
                            if any(keyword in self.keywords
                                   for keyword in data.header.strings):
                                success = True
                            else:
                                add_to_ignored_list = True

                    except ValueError:
                        log.exception("[" + file +
                                      "] - Too Big to inspect - skipping")
                    except Exception:
                        log.exception("[" + file + "] - Error")
                    finally:
                        if success:
                            self.nif_files.add(path)
                            self.nif_files_list_widget.addItem(path)
                        elif add_to_ignored_list:
                            item = QListWidgetItem(
                                path, self.ignored_nif_files_list_widget)
                            item.setForeground(Qt.darkRed)
                            ignored_files += 1
                    progress_callback.emit(0)  # emit parameter is not used
        return ignored_files