示例#1
0
        def __init__(self):
            super(self.__class__, self).__init__()
            self.setupUi(
                self)  # This is defined in design.py file automatically

            # self.listWidget_Xoutput_files.addItem("deneme")

            cleaner_files_path = os.path.join(str(QDir.currentPath()),
                                              "cleaner_files")
            if not os.path.exists(cleaner_files_path):
                os.mkdir(cleaner_files_path)

            self.model = QFileSystemModel()
            self.model.setRootPath(cleaner_files_path)

            self.model.setNameFilters(QStringList(["Xoutput-n_analyses-*.txt"
                                                   ]))
            self.model.setNameFilterDisables(False)
            self.model.setFilter(QDir.Dirs | QDir.Files)

            self.treeView_Xoutput_files.setModel(self.model)

            self.treeView_Xoutput_files.setRootIndex(
                self.model.index(cleaner_files_path))

            self.treeView_Xoutput_files.setColumnWidth(0, 500)

            self.treeView_Xoutput_files.selectionModel(
            ).selectionChanged.connect(self.load_and_view_file_contents)

            self.rules_dict = {}

            self.special_button_for_level_01.setDisabled(True)
示例#2
0
    def _iconForPath(self, path):
        """Get icon for file or directory path. Uses QFileSystemModel
        """
        if self._model is None:
            self._model = QFileSystemModel()

        index = self._model.index(path)
        return self._model.data(index, Qt.DecorationRole)
示例#3
0
 def __init__(self, parent=None):
     QLineEdit.__init__(self, parent)
     self.fsmodel = QFileSystemModel()
     self.fsmodel.setRootPath("")
     self.completer = QCompleter()
     self.completer.setModel(self.fsmodel)
     self.setCompleter(self.completer)
     self.fsmodel.setFilter(QDir.Drives | QDir.AllDirs | QDir.Hidden
                            | QDir.NoDotAndDotDot)
示例#4
0
    def load_tree(self, project):
        """Load the tree view on the right based on the project selected."""
        qfsm = QFileSystemModel()
        qfsm.setRootPath(project['path'])
        load_index = qfsm.index(qfsm.rootPath())
        # qfsm.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        # qfsm.setNameFilterDisables(False)
        # pext = ["*{0}".format(x) for x in project['extensions']]
        # qfsm.setNameFilters(pext)

        self._tree.setModel(qfsm)
        self._tree.setRootIndex(load_index)

        t_header = self._tree.header()
示例#5
0
    def __init__(self, parent=None):
        super(AttachmentView, self).__init__(parent)
        self.parent = parent
        self.settings = parent.settings

        self.model = QFileSystemModel()
        self.model.setFilter(QDir.Files)
        self.model.setRootPath(self.settings.attachmentPath)
        self.setModel(self.model)

        # self.setRootIndex(self.model.index(self.settings.attachmentPath))
        self.setViewMode(QListView.IconMode)
        self.setUniformItemSizes(True)
        self.setResizeMode(QListView.Adjust)
        self.setItemDelegate(AttachmentItemDelegate(self))
        self.clicked.connect(self.click)
示例#6
0
 def paintEvent(self, event):
     self.splitter = QSplitter()
     model = QFileSystemModel()
     model.setRootPath(QDir.rootPath())
     # model.setRootPath(idahome)
     # using ida home instead
     views = []
     for ViewType in (QColumnView, QTreeView):
         view = ViewType(self.splitter)
         view.setModel(model)
         view.setRootIndex(model.index(idahome))
         view.setDragEnabled(True)
         view.setAcceptDrops(True)
         view.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
     # splitter.show()
     # Create layout
     layout = QtGui.QVBoxLayout(self)
     # layout.addWidget(self.comboList)
     layout.addWidget(self.splitter)
示例#7
0
 def open_project(self, project):
     project_path = project.path
     qfsm = None  # Should end up having a QFileSystemModel
     if project_path not in self.__projects:
         qfsm = QFileSystemModel()
         project.model = qfsm
         qfsm.setRootPath(project_path)
         qfsm.setFilter(QDir.AllDirs | QDir.Files | QDir.NoDotAndDotDot)
         # If set to true items that dont match are displayed disabled
         qfsm.setNameFilterDisables(False)
         pext = ["*{0}".format(x) for x in project.extensions]
         logger.debug(pext)
         qfsm.setNameFilters(pext)
         self.__projects[project_path] = project
         self.__check_files_for(project_path)
         self.emit(SIGNAL("projectOpened(PyQt_PyObject)"), project)
     else:
         qfsm = self.__projects[project_path]
     return qfsm
示例#8
0
    def __init__(self):
        QWidget.__init__(self)
        hbox = QHBoxLayout(self)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.btnClose = QPushButton(
            self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self.completer = QCompleter(self)
        self.pathLine = ui_tools.LineEditTabCompleter(self.completer)
        fileModel = QFileSystemModel(self.completer)
        fileModel.setRootPath("")
        self.completer.setModel(fileModel)
        self.pathLine.setCompleter(self.completer)
        self.btnOpen = QPushButton(
            self.style().standardIcon(QStyle.SP_ArrowRight), 'Open!')
        hbox.addWidget(self.btnClose)
        hbox.addWidget(QLabel(self.trUtf8("Path:")))
        hbox.addWidget(self.pathLine)
        hbox.addWidget(self.btnOpen)

        self.connect(self.pathLine, SIGNAL("returnPressed()"), self._open_file)
        self.connect(self.btnOpen, SIGNAL("clicked()"), self._open_file)
示例#9
0
    def load_tree(self, project):
        """Load the tree view on the right based on the project selected."""
        qfsm = QFileSystemModel()
        qfsm.setRootPath(project.path)
        load_index = qfsm.index(qfsm.rootPath())
        qfsm.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        qfsm.setNameFilterDisables(False)
        pext = ["*{0}".format(x) for x in project.extensions]
        qfsm.setNameFilters(pext)

        self._tree.setModel(qfsm)
        self._tree.setRootIndex(load_index)

        t_header = self._tree.header()
        t_header.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
        t_header.setResizeMode(0, QHeaderView.Stretch)
        t_header.setStretchLastSection(False)
        t_header.setClickable(True)

        self._tree.hideColumn(1)  # Size
        self._tree.hideColumn(2)  # Type
        self._tree.hideColumn(3)  # Modification date
示例#10
0
    def __init__(self, *args):
        super(FileBrowser, self).__init__(*args)

        layout = QVBoxLayout()
        model = QFileSystemModel()

        filters = ["*.jpg", "*.JPG", "*.jpeg", "*.JPEG", "*.png", "*.PNG"]
        model.setNameFilters(filters)

        self.directoryTree = QTreeView()
        self.directoryTree.setModel(model)
        self.directoryTree.currentChanged = self.currentChanged
        self.directoryTree.setSortingEnabled(True)
        self.directoryTree.sortByColumn(0, Qt.AscendingOrder)

        self.fileList = QListWidget()

        layout.addWidget(self.directoryTree)
        self.setLayout(layout)

        root = model.setRootPath(QDir.homePath())
        self.directoryTree.setRootIndex(root)
示例#11
0
    def __init__(self, parent=None):
        QTreeView.__init__(self)
        self.header().setHidden(True)
        self.setAnimated(True)

        # Modelo
        self.model = QFileSystemModel(self)
        path = QDir.toNativeSeparators(QDir.homePath())
        self.model.setRootPath(path)
        self.setModel(self.model)
        self.model.setNameFilters(["*.c", "*.h", "*.s"])
        self.setRootIndex(QModelIndex(self.model.index(path)))
        self.model.setNameFilterDisables(False)

        # Se ocultan algunas columnas
        self.hideColumn(1)
        self.hideColumn(2)
        self.hideColumn(3)

        # Conexion
        self.doubleClicked.connect(self._open_file)

        Edis.load_lateral("explorer", self)
示例#12
0
    def __init__(self, root, parent=None):
        super(MFileTree, self).__init__(parent)
        self.setStyleSheet("color:rgb(189, 195, 199);")
        # model = QFileSystemModel()
        # model.setRootPath(QDir.rootPath())
        # view = QTreeView(parent)
        # self.show()
        #app = QApplication(sys.argv)
        # Splitter to show 2 views in same widget easily.
        splitter = QSplitter()
        # The model.
        model = QFileSystemModel()
        # You can setRootPath to any path.
        model.setRootPath(root)
        # List of views.
        self.views = []
        #self.view = QTreeView(self)
        # self.itemPressed.connect(self.itemClicked)
        self.setModel(model)
        self.setRootIndex(model.index(root))
        self.header().setStyleSheet("background:rgb(70, 80, 88);")
        # for ViewType in (QColumnView, QTreeView):
        # # Create the view in the splitter.
        # view = ViewType(splitter)
        # # Set the model of the view.
        # view.setModel(model)
        # # Set the root index of the view as the user's home directory.
        # view.setRootIndex(model.index(QDir.homePath()))
        # # Show the splitter.
        # splitter.show()
        self.layout = QtGui.QHBoxLayout()
        # self.layout.addWidget(self)

        self.setLayout(self.layout)

        # Maximize the splitter.
        splitter.setWindowState(Qt.WindowMaximized)
示例#13
0
文件: datawidget.py 项目: nsashi/Roam
    def __init__(self, parent=None):
        super(DataWidget, self).__init__(parent)
        self.setupUi(self)
        self.model = QFileSystemModel()
        self.settings = None
        allfilters = []
        filters = re.findall(
            r"\((.*?)\)",
            QgsProviderRegistry.instance().fileVectorFilters())[1:]
        for filter in filters:
            allfilters = allfilters + filter.split(" ")

        filters += re.findall(
            r"\((.*?)\)",
            QgsProviderRegistry.instance().fileRasterFilters())[1:]
        for filter in filters:
            allfilters = allfilters + filter.split(" ")
        self.model.setNameFilters(allfilters)
        self.model.setNameFilterDisables(False)
        self.listDataList.setModel(self.model)
        self.btnAddData.pressed.connect(self.open_data_folder)
        for col in range(self.model.columnCount())[1:]:
            self.listDataList.hideColumn(col)
        self.service = None
示例#14
0
class AbstractPathCompleter(AbstractCompleter):
    """Base class for PathCompleter and GlobCompleter
    """

    # global object. Reused by all completers
    _fsModel = QFileSystemModel()

    _ERROR = 'error'
    _HEADER = 'currentDir'
    _STATUS = 'status'
    _DIRECTORY = 'directory'
    _FILE = 'file'

    def __init__(self, text):
        self._originalText = text
        self._dirs = []
        self._files = []
        self._error = None
        self._status = None
        """hlamer: my first approach is making self._model static member of class. But, sometimes it 
        returns incorrect icons. I really can't understand when and why.
        When it is private member of instance, it seems it works
        """
        self._model = None  # can't construct in the construtor, must be constructed in GUI thread

    @staticmethod
    def _filterHidden(paths):
        """Remove hidden and ignored files from the list
        """
        return [path for path in paths \
                    if not os.path.basename(path).startswith('.') and \
                        not core.fileFilter().regExp().match(path)]

    def _classifyRowIndex(self, row):
        """Get list item type and index by it's row
        """

        if self._error:
            assert row == 0
            return (self._ERROR, 0)

        if row == 0:
            return (self._HEADER, 0)

        row -= 1
        if self._status:
            if row == 0:
                return (self._STATUS, 0)
            row -= 1

        if row in range(len(self._dirs)):
            return (self._DIRECTORY, row)
        row -= len(self._dirs)

        if row in range(len(self._files)):
            return (self._FILE, row)

        assert False

    def _formatHeader(self, text):
        """Format current directory for show it in the list of completions
        """
        return '<font style="background-color: %s; color: %s">%s</font>' % \
                (QApplication.instance().palette().color(QPalette.Window).name(),
                 QApplication.instance().palette().color(QPalette.WindowText).name(),
                 htmlEscape(text))

    def rowCount(self):
        """Row count in the list of completions
        """
        if self._error:
            return 1
        else:
            count = 1  # current directory
            if self._status:
                count += 1
            count += len(self._dirs)
            count += len(self._files)
            return count

    def _iconForPath(self, path):
        """Get icon for file or directory path. Uses QFileSystemModel
        """
        if self._model is None:
            self._model = QFileSystemModel()

        index = self._model.index(path)
        return self._model.data(index, Qt.DecorationRole)

    def text(self, row, column):
        """Item text in the list of completions
        """
        rowType, index = self._classifyRowIndex(row)
        if rowType == self._ERROR:
            return '<font color=red>%s</font>' % htmlEscape(self._error)
        elif rowType == self._HEADER:
            return self._formatHeader(self._headerText())
        elif rowType == self._STATUS:
            return '<i>%s</i>' % htmlEscape(self._status)
        elif rowType == self._DIRECTORY:
            return self._formatPath(self._dirs[index], True)
        elif rowType == self._FILE:
            return self._formatPath(self._files[index], False)

    def icon(self, row, column):
        """Item icon in the list of completions
        """
        rowType, index = self._classifyRowIndex(row)
        if rowType == self._ERROR:
            return QApplication.instance().style().standardIcon(
                QStyle.SP_MessageBoxCritical)
        elif rowType == self._HEADER:
            return None
        elif rowType == self._STATUS:
            return None
        elif rowType == self._DIRECTORY:
            return self._iconForPath(self._dirs[index])
        elif rowType == self._FILE:
            return self._iconForPath(self._files[index])

    def getFullText(self, row):
        """User clicked a row. Get inline completion for this row
        """
        row -= 1  # skip current directory
        path = None
        if row in range(len(self._dirs)):
            return self._dirs[row] + '/'
        else:
            row -= len(self._dirs)  # skip dirs
            if row in range(len(self._files)):
                return self._files[row]

        return None
示例#15
0
 def __init__(self, parent=None):
     super(OrLogsListView, self).__init__(parent)
     self.model = QFileSystemModel()
     self.model.sort(3, Qt.DescendingOrder)
     self.model.setFilter(QDir.Files)
     self.setModel(self.model)
示例#16
0
    def __init__(self):
        self.techniquesClass = {
            'caesar cipher': caesarCipher,
            'mono alphabetic cipher': monoAlphabeticCipher,
            'vigenere cipher': vigenereCipher,
            'vernan cipher': vernanCipher,
            'one time pad': oneTimePad
        }

        self.rowsview = []
        self.filesview = []
        #self.techniques = []

        QDialog.__init__(self)
        self.setWindowTitle("Desencriptador de Cryogenesis Systems.")
        self.resize(1024, 600)
        self.setMinimumSize(QSize(1024, 600))
        self.setMaximumSize(QSize(1024, 600))

        self.checkBox_2 = QCheckBox(self)
        self.checkBox_2.setGeometry(QRect(620, 10, 130, 20))
        self.checkBox_2.setText('seleccionar todos')
        self.checkBox_2.clicked.connect(self.__selectAllFiles)

        self.treeView = QTreeView(self)
        self.treeView.setGeometry(QRect(10, 10, 230, 580))
        self.treeView.setObjectName("treeView")

        self.fileSystemModel = QFileSystemModel(self.treeView)
        self.fileSystemModel.setReadOnly(False)

        self.fileSystemModel.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        root = self.fileSystemModel.setRootPath("/")
        self.treeView.setModel(self.fileSystemModel)
        self.treeView.setRootIndex(root)
        self.treeView.hideColumn(1)
        self.treeView.hideColumn(2)
        self.treeView.hideColumn(3)
        self.treeView.clicked.connect(self.__eventDirectoryChanged)

        self.mygroupbox = QGroupBox(self)
        self.mygroupbox.setGeometry(QRect(0, 0, 1000, 1000))
        self.myform = QFormLayout()
        for j in list(range(100)):
            horizontalLayout = QHBoxLayout()
            self.myform.addRow(horizontalLayout)
            self.rowsview.append(horizontalLayout)

        self.mygroupbox.setLayout(self.myform)
        scroll = QScrollArea(self)
        scroll.setWidget(self.mygroupbox)
        scroll.setWidgetResizable(True)
        scroll.setGeometry(QRect(250, 30, 500, 580))
        scroll.setWidgetResizable(True)

        self.label_4 = QLabel(self)
        self.label_4.setGeometry(QRect(780, 30, 31, 16))
        self.label_4.setPixmap(QPixmap("images/key.png"))
        self.label_4.setScaledContents(True)

        self.lineEdit = QLineEdit(self)
        self.lineEdit.setGeometry(QRect(820, 30, 180, 20))
        self.lineEdit.setObjectName("lineEdit")
        self.lineEdit.setPlaceholderText(_fromUtf8('escriba su contraseña'))
        self.lineEdit.setEchoMode(QLineEdit.Password)

        self.okButton = QPushButton(self)
        self.okButton.setGeometry(QRect(920, 560, 80, 20))
        self.okButton.setText('Iniciar...')
        self.connect(self.okButton, SIGNAL("clicked()"),
                     self.__eventInitDecryption)
示例#17
0
    def __init__(self):
        self.techniquesClass = {
            'caesar cipher': caesarCipher,
            'mono alphabetic cipher': monoAlphabeticCipher,
            'vigenere cipher': vigenereCipher,
            'vernan cipher': vernanCipher,
            'one time pad': oneTimePad
        }

        self.rowsview = []
        self.filesview = []
        self.techniques = []

        QDialog.__init__(self)
        self.setWindowTitle("CryptoSystems")
        self.resize(1024, 600)
        self.setMinimumSize(QSize(1024, 600))
        self.setMaximumSize(QSize(1024, 600))

        self.checkBox_2 = QCheckBox(self)
        self.checkBox_2.setGeometry(QRect(620, 10, 130, 20))
        self.checkBox_2.setText('Select All')
        self.checkBox_2.clicked.connect(self.__selectAllFiles)

        self.treeView = QTreeView(self)
        self.treeView.setGeometry(QRect(10, 10, 230, 580))
        self.treeView.setObjectName("treeView")

        self.fileSystemModel = QFileSystemModel(self.treeView)
        self.fileSystemModel.setReadOnly(False)

        self.fileSystemModel.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        root = self.fileSystemModel.setRootPath("/")
        self.treeView.setModel(self.fileSystemModel)
        self.treeView.setRootIndex(root)
        self.treeView.hideColumn(1)
        self.treeView.hideColumn(2)
        self.treeView.hideColumn(3)
        self.treeView.clicked.connect(self.__eventDirectoryChanged)

        self.mygroupbox = QGroupBox(self)
        self.mygroupbox.setGeometry(QRect(0, 0, 1000, 1000))
        self.myform = QFormLayout()
        for j in list(range(100)):
            horizontalLayout = QHBoxLayout()
            self.myform.addRow(horizontalLayout)
            self.rowsview.append(horizontalLayout)

        self.mygroupbox.setLayout(self.myform)
        scroll = QScrollArea(self)
        scroll.setWidget(self.mygroupbox)
        scroll.setWidgetResizable(True)
        scroll.setGeometry(QRect(250, 30, 500, 580))
        scroll.setWidgetResizable(True)

        self.label_4 = QLabel(self)
        self.label_4.setGeometry(QRect(780, 30, 31, 16))
        self.label_4.setPixmap(QPixmap("images/key.png"))
        self.label_4.setScaledContents(True)

        self.lineEdit = QLineEdit(self)
        self.lineEdit.setGeometry(QRect(820, 30, 180, 20))
        self.lineEdit.setObjectName("lineEdit")
        self.lineEdit.setPlaceholderText(_fromUtf8('write your password'))
        self.lineEdit.setEchoMode(QLineEdit.Password)

        self.techniquesGroup = QGroupBox(self)
        self.tecniquesform = QFormLayout()
        self.techniquesGroup.setLayout(self.tecniquesform)

        self.techniquesScroll = QScrollArea(self)
        self.techniquesScroll.setGeometry(QRect(770, 100, 230, 300))
        self.techniquesScroll.setWidget(self.techniquesGroup)
        self.techniquesScroll.setWidgetResizable(True)

        self.rowsTechiques = []
        for i in list(range(8)):
            horizontalLayout = QHBoxLayout()
            self.tecniquesform.addRow(horizontalLayout)
            self.rowsTechiques.append(horizontalLayout)

        techniquesCombo = QComboBox()
        techniquesCombo.setGeometry(QRect(10, 50, 171, 22))
        techniquesCombo.addItems(self.techniquesClass.keys())
        self.techniques.append(techniquesCombo)
        self.rowsTechiques[0].addWidget(techniquesCombo)
        self.techniquesNumber = 1

        self.addTechnique = QPushButton()
        self.addTechnique.setGeometry(QRect(90, 90, 31, 21))
        self.addTechnique.setFixedSize(31, 21)
        self.addTechnique.setText('+')
        self.connect(self.addTechnique, SIGNAL("clicked()"),
                     self.__eventAddTechnique)
        self.rowsTechiques[len(self.rowsTechiques) - 1].addWidget(
            self.addTechnique)

        self.okButton = QPushButton(self)
        self.okButton.setGeometry(QRect(920, 560, 80, 20))
        self.okButton.setText('Start...')
        self.connect(self.okButton, SIGNAL("clicked()"),
                     self.__eventInitEncryption)
示例#18
0
文件: explorer.py 项目: koll00/Gui_SM
 def setup_fs_model(self):
     """Setup filesystem model"""
     filters = QDir.AllDirs | QDir.Files | QDir.Drives | QDir.NoDotAndDotDot
     self.fsmodel = QFileSystemModel(self)
     self.fsmodel.setFilter(filters)
     self.fsmodel.setNameFilterDisables(False)
示例#19
0
@license : 
@contact : ****@massclouds.com
@site    : http://blog.csdn.net/***
@software: PyCharm
@time    : 17-1-5 下午5:19
"""

from PyQt4.QtGui import QApplication,QTreeView,QFileSystemModel, QListView
from PyQt4.QtCore import QDir
import sys


if __name__ == '__main__':
    app = QApplication(sys.argv)
    # 1. 创建 模型 model  */
    model = QFileSystemModel()            # 创建文件系统模型
    model.setRootPath(QDir.currentPath()) # 指定要监视的目录

    # 2. 创建 视图 view  */
    tree = QTreeView()                                 # 创建树型视图
    tree.setModel(model)                               # 为视图指定模型
    tree.setRootIndex(model.index(QDir.currentPath() ))# 指定根索引

    listw = QListView()                                # 创建列表视图
    listw.setModel(model)                              # 为视图指定模型
    listw.setRootIndex(model.index(QDir.currentPath()))# 指定根索引

    tree.setWindowTitle("QTreeView")
    tree.show()
    listw.setWindowTitle("QListView")
    listw.show()
示例#20
0
import sys

from PyQt4.QtGui import (QApplication, QColumnView, QFileSystemModel,
                         QSplitter, QTreeView)
from PyQt4.QtCore import QDir, Qt

if __name__ == '__main__':
    app = QApplication(sys.argv)
    # Splitter to show 2 views in same widget easily.
    splitter = QSplitter()
    # The model.
    model = QFileSystemModel()
    # You can setRootPath to any path.
    model.setRootPath(QDir.rootPath())
    # List of views.
    views = []
    for ViewType in (QColumnView, QTreeView):
        # Create the view in the splitter.
        view = ViewType(splitter)
        # Set the model of the view.
        view.setModel(model)
        # Set the root index of the view as the user's home directory.
        view.setRootIndex(model.index(QDir.homePath()))
    # Show the splitter.
    splitter.show()
    # Maximize the splitter.
    splitter.setWindowState(Qt.WindowMaximized)
    # Start the main loop.
    sys.exit(app.exec_())