コード例 #1
0
ファイル: ui.py プロジェクト: pyq881120/flare-wmi
    def _handle_results_item_activated(self, itemIndex):
        emptyLayout(self._ui.queryResultsViewLayout)
        item = self._query_model.itemFromIndex(itemIndex).data()

        if isinstance(item, Key):
            buf = self._ctx.object_resolver.get_object(item)
            self._save_buffer = buf
            hv = HexViewWidget(buf, self._ui.queryResultsViewFrame)
            self._ui.queryResultsViewLayout.addWidget(hv)

        elif isinstance(item, ClassDefinitionItem):
            v = ClassDefinitionItemView(item, self._ui.queryResultsViewFrame)
            self._save_buffer = item.data
            self._ui.queryResultsViewLayout.addWidget(v)

        elif isinstance(item, ClassInstanceItem):
            v = ClassInstanceItemView(item, self._ui.queryResultsViewFrame)
            self._save_buffer = item.data
            self._ui.queryResultsViewLayout.addWidget(v)

        elif isinstance(item, NamespaceItem):
            l = QLabel(self._ui.queryResultsViewFrame)
            l.setText("Don't know how to display namespaces yet")
            self.w("dont know how to display namespaces")
            self._ui.queryResultsViewLayout.addWidget(l)
コード例 #2
0
ファイル: ui.py プロジェクト: pyq881120/flare-wmi
    def _handle_query(self):
        viewLayout = self._ui.queryResultsViewLayout
        emptyLayout(viewLayout)
        self._query_model.clear()

        query_text = self._ui.queryInputLineEdit.text()
        self.d("query: %s", query_text)
        if query_text.startswith("NS_"):
            self.d("key query")
            for o in self._ctx.object_resolver.get_keys(Key(query_text)):
                self.d("  query result: %s", o)
                item = QStandardItem(o.human_format)
                item.setData(o)
                self._query_model.appendRow(item)
        elif query_text.lower().startswith("root"):
            self.d("logical query (missing host)")
            # TODO: reference to Moniker is broken
            # need reference to a namespace to .parse_object_path(), and .get()
            m = Moniker("//./" + query_text)
            self._handle_moniker_query(m)
        elif query_text.lower().startswith("//"):
            self.d("logical query")
            m = Moniker(query_text)
            self._handle_moniker_query(m)
        elif query_text.lower().startswith("winmgmts:"):
            self.d("logical query (winmgmnts)")
            m = Moniker(query_text)
            self._handle_moniker_query(m)
        else:
            self.w("unknown query schema: %s", query_text)
コード例 #3
0
ファイル: ui.py プロジェクト: pyq881120/flare-wmi
    def _handle_browse_item_activated(self, itemIndex):
        item = self._tree_model.getIndexData(itemIndex)
        details = self._ui.browseDetails
        details_layout = self._ui.browseDetailsLayout
        emptyLayout(details_layout)

        if isinstance(item, PhysicalDataPageItem):
            v = PhysicalDataPageItemView(item, details)
            details_layout.addWidget(v)

        elif isinstance(item, LogicalDataPageItem):
            v = LogicalDataPageItemView(item, details)
            details_layout.addWidget(v)

        elif isinstance(item, PhysicalIndexPageItem):
            v = PhysicalIndexPageItemView(item, details)
            details_layout.addWidget(v)

        elif isinstance(item, LogicalIndexPageItem):
            v = LogicalIndexPageItemView(item, details)
            details_layout.addWidget(v)

        elif isinstance(item, IndexNodeItem):
            v = IndexNodeItemView(item, details)
            details_layout.addWidget(v)

        elif isinstance(item, IndexKeyItem):
            v = IndexKeyItemView(item, details)
            details_layout.addWidget(v)

        elif isinstance(item, ClassDefinitionItem):
            v = ClassDefinitionItemView(item, details)
            details_layout.addWidget(v)

        elif isinstance(item, ClassInstanceItem):
            v = ClassInstanceItemView(item, details)
            details_layout.addWidget(v)
コード例 #4
0
ファイル: ui.py プロジェクト: pyq881120/flare-wmi
    def __init__(self, ctx, parent=None):
        super(CimUiForm, self).__init__(parent)
        self._ctx = ctx
        self._tree_model = TreeModel(
                CimRootItem(ctx),
                [
                    ColumnDef("Name", "name"),
                    ColumnDef("Type", "type"),
                ])

        # TODO: maybe subclass the loaded .ui and use that instance directly

        uipath = os.path.join(os.path.dirname(os.path.realpath(__file__)), os.path.join("ui", "ui.ui"))
        self._ui = uic.loadUi(uipath)
        emptyLayout(self._ui.browseDetailsLayout)

        tv = self._ui.browseTreeView
        tv.setModel(self._tree_model)
        tv.header().setSectionResizeMode(QHeaderView.Interactive)
        tv.header().resizeSection(0, 250)  # chosen empirically
        tv.activated.connect(self._handle_browse_item_activated)

        self._query_model = QStandardItemModel(self._ui.queryResultsList)
        self._ui.queryResultsList.setModel(self._query_model)
        self._ui.queryInputLineEdit.returnPressed.connect(self._handle_query)
        self._ui.queryInputActionButton.clicked.connect(self._handle_query)
        self._ui.queryResultsList.activated.connect(self._handle_results_item_activated)

        self._save_buffer = None
        self._ui.queryResultsSaveButton.clicked.connect(self._handle_save)

        mainLayout = QGridLayout()
        mainLayout.addWidget(self._ui, 0, 0)

        self.setLayout(mainLayout)
        self.setWindowTitle("cim - ui")