Esempio n. 1
0
    def __init__(self, parent=None, f=0):
        """
        UI Element property inspector made up of two QTreeViews
        """

        QWidget.__init__(self, parent)

        self.ui = Ui_TrickplayInspector()
        self.ui.setupUi(self)
        self.ui.refresh.setEnabled(False)
        self.ui.search.setEnabled(False)

        # Ignore signals while updating elements internally
        self.preventChanges = False

        # Searches find multiple items with the same name
        #self.lastSearchedText = None
        #self.lastSearchedItem = None

        # Models
        self.inspectorModel = TrickplayElementModel(self)
        self.propertyModel = TrickplayPropertyModel()

        self.ui.inspector.setModel(self.inspectorModel)
        self.ui.property.setModel(self.propertyModel)

        self.ui.lineEdit.setPlaceholderText("Search by GID or Name")

        self.setHeaders(self.inspectorModel, ['UI Element', 'Name'])
        self.setHeaders(self.propertyModel, ['Property', 'Value'])

        # QTreeView selectionChanged signal doesn't seem to work here...
        # Use the selection model instead
        QObject.connect(
            self.ui.inspector.selectionModel(),
            SIGNAL('selectionChanged(QItemSelection, QItemSelection)'),
            self.selectionChanged)

        # For changing checkboxes (visibility)
        QObject.connect(
            self.inspectorModel,
            SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"),
            self.inspectorDataChanged)

        # For changing UI Element properties
        QObject.connect(
            self.propertyModel,
            SIGNAL("dataChanged(const QModelIndex&,const QModelIndex&)"),
            self.propertyDataChanged)

        QObject.connect(self.ui.refresh, SIGNAL("clicked()"), self.refresh)

        QObject.connect(self.ui.search, SIGNAL("clicked()"), self.userSearch)

        QObject.connect(self.ui.lineEdit, SIGNAL('returnPressed()'),
                        self.userSearch)