Python PyQt5.QtWidgets.QFileSystemModel() Examples

The following are 7 code examples of PyQt5.QtWidgets.QFileSystemModel(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: models.py    From Lector with GNU General Public License v3.0 5 votes vote down vote up
def columnCount(self, parent):
        # The QFileSystemModel returns 4 columns by default
        # Columns 1, 2, 3 will be present but hidden
        return 6 
Example #2
Source File: models.py    From Lector with GNU General Public License v3.0 5 votes vote down vote up
def data(self, index, role):
        if (index.column() in (4, 5)
                and (role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole)):

            read_field = self.field_dict[index.column()]
            try:
                return self.tag_data[self.filePath(index)][read_field]
            except KeyError:
                return QtCore.QVariant()

        if role == QtCore.Qt.CheckStateRole and index.column() == 0:
            return self.checkState(index)

        return QtWidgets.QFileSystemModel.data(self, index, role) 
Example #3
Source File: models.py    From Lector with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
        if index.column() in (4, 5):
            return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable
        else:
            return QtWidgets.QFileSystemModel.flags(self, index) | QtCore.Qt.ItemIsUserCheckable 
Example #4
Source File: config.py    From kite with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        QtWidgets.QDialog.__init__(self, *args, **kwargs)

        self.completer = QtWidgets.QCompleter()
        self.completer_model = QtWidgets.QFileSystemModel(self.completer)
        self.completer.setModel(self.completer_model)
        self.completer.setMaxVisibleItems(8)

        loadUi(get_resource('dialog_config.ui'), self)

        self.ok_button.released.connect(
            self.setAttributes)
        self.ok_button.released.connect(
            self.close)

        self.apply_button.released.connect(
            self.setAttributes)

        self.vector_color_picker = QtWidgets.QColorDialog(self)
        self.vector_color_picker. \
            setCurrentColor(QtGui.QColor(*getConfig().vector_color))
        self.vector_color_picker. \
            setOption(self.vector_color_picker.ShowAlphaChannel)
        self.vector_color_picker.colorSelected.connect(
            self.updateVectorColor)
        self.vector_color_picker.setModal(True)
        self.vector_color.clicked.connect(
            self.vector_color_picker.show)

        self.vector_color.setValue = self.setButtonColor
        self.vector_color.value = self.getButtonColor

        self.chooseStoreDirButton.released.connect(
            self.chooseStoreDir)
        self.completer_model.setRootPath('')
        self.completer.setParent(self.default_gf_dir)
        self.default_gf_dir.setCompleter(self.completer)

        self.getAttributes() 
Example #5
Source File: Directory.py    From Hydra with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, callback, app=None, palette=None):
        super().__init__()

        directoryFont = QFont()
        self.app = app
        self.palette = palette

        self.currentPath: str = ""
        self.indexPath: str = ""

        directoryFont.setFamily(editor["directoryFont"])
        directoryFont.setPointSize(editor["directoryFontSize"])
        self.open_callback = callback
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.openMenu)
        self.setFont(directoryFont)
        self.layout = QHBoxLayout()
        self.model = QFileSystemModel()
        self.setModel(self.model)
        self.model.setRootPath(QDir.rootPath())
        self.setMaximumWidth(300)
        self.setIndentation(10)
        self.setAnimated(True)
        self.newFile()
        self.deleteFile()
        self.setSortingEnabled(True)
        self.setWindowTitle("Dir View")
        self.hideColumn(1)
        self.resize(200, 600)
        self.hideColumn(2)
        self.confirmation = MessageBox(self)
        self.hideColumn(3)
        self.doubleClicked.connect(self.openFile) 
Example #6
Source File: gui.py    From pbtk with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
        super().__init__(argv)
        signal(SIGINT, SIG_DFL)
        
        views = dirname(realpath(__file__)) + '/views/'
        
        self.welcome = loadUi(views + 'welcome.ui')
        self.choose_extractor = loadUi(views + 'choose_extractor.ui')
        self.choose_proto = loadUi(views + 'choose_proto.ui')
        self.create_endpoint = loadUi(views + 'create_endpoint.ui')
        self.choose_endpoint = loadUi(views + 'choose_endpoint.ui')
        self.fuzzer = loadUi(views + 'fuzzer.ui')

        self.welcome.step1.clicked.connect(self.load_extractors)
        self.choose_extractor.rejected.connect(partial(self.set_view, self.welcome))
        self.choose_extractor.extractors.itemClicked.connect(self.prompt_extractor)
        
        self.welcome.step2.clicked.connect(self.load_protos)
        self.proto_fs = QFileSystemModel()
        self.choose_proto.protos.setModel(self.proto_fs)
        self.proto_fs.directoryLoaded.connect(self.choose_proto.protos.expandAll)
        
        for i in range(1, self.proto_fs.columnCount()):
            self.choose_proto.protos.hideColumn(i)
        self.choose_proto.protos.setRootIndex(self.proto_fs.index(str(BASE_PATH / 'protos')))
        self.choose_proto.rejected.connect(partial(self.set_view, self.welcome))
        self.choose_proto.protos.clicked.connect(self.new_endpoint)
        
        self.create_endpoint.transports.itemClicked.connect(self.pick_transport)
        self.create_endpoint.loadRespPbBtn.clicked.connect(self.load_another_pb)
        self.create_endpoint.rejected.connect(partial(self.set_view, self.choose_proto))
        self.create_endpoint.buttonBox.accepted.connect(self.write_endpoint)
                
        self.welcome.step3.clicked.connect(self.load_endpoints)
        self.choose_endpoint.rejected.connect(partial(self.set_view, self.welcome))
        self.choose_endpoint.endpoints.itemClicked.connect(self.launch_fuzzer)
        
        self.fuzzer.rejected.connect(partial(self.set_view, self.choose_endpoint))
        self.fuzzer.fuzzFields.clicked.connect(self.fuzz_endpoint)
        self.fuzzer.deleteThis.clicked.connect(self.delete_endpoint)
        self.fuzzer.comboBox.activated.connect(self.launch_fuzzer)
        self.fuzzer.getAdd.clicked.connect(self.add_tab_data)

        self.fuzzer.urlField.setWordWrapMode(QTextOption.WrapAnywhere)
        
        for tree in (self.fuzzer.pbTree, self.fuzzer.getTree):
            tree.itemEntered.connect(lambda item, _: item.edit() if hasattr(item, 'edit') else None)
            tree.itemClicked.connect(lambda item, col: item.update_check(col=col))
            tree.itemExpanded.connect(lambda item: item.expanded() if hasattr(item, 'expanded') else None)
            tree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
        
        self.welcome.mydirLabel.setText(self.welcome.mydirLabel.text() % BASE_PATH)
        self.welcome.mydirBtn.clicked.connect(partial(QDesktopServices.openUrl, QUrl.fromLocalFile(str(BASE_PATH))))
        
        self.set_view(self.welcome)
        self.exec_() 
Example #7
Source File: media_library.py    From code-jam-5 with MIT License 4 votes vote down vote up
def init_ui(self):

        layout = QtWidgets.QVBoxLayout()
        self.setLayout(layout)

        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(0)

        self.title_frame = QtWidgets.QFrame()
        self.title_frame.setStyleSheet('background: #57bd4f;'
                                       'border-top-left-radius: 6px;'
                                       'border-top-right-radius: 6px;'
                                       'color: white;')

        self.title_layout = QtWidgets.QHBoxLayout()
        self.title_frame.setLayout(self.title_layout)
        self.layout().addWidget(self.title_frame)

        self.library_frame = QtWidgets.QFrame()
        self.library_frame.setStyleSheet('background: #78543b;'
                                         'border-bottom-left-radius: 6px;'
                                         'border-bottom-right-radius: 6px;'
                                         'color: white;')
        self.library_layout = QtWidgets.QVBoxLayout()
        self.library_frame.setLayout(self.library_layout)
        self.layout().addWidget(self.library_frame)

        title_font = QtGui.QFont('Raleway', 16)
        title_font.setBold(True)

        self.media_library_title = QtWidgets.QLabel('Media Library')
        self.media_library_title.setFont(title_font)

        self.title_layout.addWidget(self.media_library_title)

        self.filesystem_model = QtWidgets.QFileSystemModel()
        self.filesystem_model.setNameFilters(['*.mp3', '*.m4a', '*.wav', '*.m3u', '*.ogg', '*.wma'])
        self.filesystem_model.setNameFilterDisables(False)
        self.filesystem_model.setFilter(QtCore.QDir.AllEntries | QtCore.QDir.NoDotAndDotDot)

        self.music_tree = QtWidgets.QTreeView(self)
        self.music_tree.setModel(self.filesystem_model)

        self.music_tree.hideColumn(1)  # Size Column
        self.music_tree.hideColumn(2)  # Type Column
        self.music_tree.hideColumn(3)  # Date Modified Column

        self.music_tree.setObjectName('music_library')
        self.music_tree.setHeaderHidden(True)

        # Add slot
        self.music_tree.activated.connect(self.item_clicked)

        # Add widget
        self.library_layout.addWidget(self.music_tree)

        self.change_path_button = QtWidgets.QPushButton('Change Path')
        self.library_layout.addWidget(self.change_path_button)
        self.change_path_button.clicked.connect(self.choose_path)