def _startSearching(self): ''' Starts the searching process. ''' self.buttonNext.setVisible(True) self.buttonNext.setEnabled(False) self.buttonSearch.setVisible(False) self.buttonStop.setEnabled(True) explorerDev = self._view.deviceTabAtIndex() if explorerDev is None: runWarning("No device is connected.", "Search unavailable") self.searchingStoppedUpdateState() return currentPath = explorerDev.selectedItemPath() if currentPath: if not explorerDev.itemExists(currentPath): self.searchingStoppedUpdateState() return else: runInformation("No item is selected.", "Search unavailable") self.searchingStoppedUpdateState() log.warning("Search cannot be performed since no reference item" " is selected") return self._explorerDev = explorerDev self._explorerDev.startItemChanged.connect(self._startItemChanged) self._explorerDev.itemFound.connect(self.itemFoundUpdateState) self._explorerDev.itemNotFound.connect(self.itemNotFoundUpdateState) self._explorerDev.searchingStopped.connect(self._stopSearching) self._searching = True criteria = { 'name': self._name, 'role': self._role, 'state': self._state, 'text': self._text, 'matchType': self._matchType, 'caseSensitiveMatch': self._caseSensitiveMatch } deep = False if self._method == self._DEEP_METHOD: deep = True try: explorerDev.find(self.Check(criteria), deep) self._lastNames.add(self._name) if self._role: self._lastRoles.add(self._role) if self._state: self._lastStates.add(self._state) self._manualUpdate = True self._refreshCompleters() self._manualUpdate = False self._saveState() except: self._stopSearching()
def itemNotFoundUpdateState(self): ''' Updates buttons after the item is not found. ''' self.buttonNext.setVisible(False) self.buttonNext.setDefault(False) self.buttonSearch.setVisible(True) self.buttonSearch.setEnabled(True) self.buttonSearch.setDefault(True) self.buttonStop.setVisible(True) self.buttonStop.setEnabled(False) runInformation("No items found.", "Search finished")