def onFileContextMenuAboutToShow(self): """Called when the plugin file context menu is about to show""" path = str(self.fileParentMenu.menuAction().data().toString()) pathStatus = self.getLocalStatus(path) debugMode = self.ide.mainWindow.debugMode if pathStatus == IND_ERROR: self.fileContextInfoAct.setEnabled(False) self.fileContextUpdateAct.setEnabled(False) self.fileContextAnnotateAct.setEnabled(False) self.fileContextLogAct.setEnabled(False) self.fileContextAddAct.setEnabled(False) self.fileContextCommitAct.setEnabled(False) self.fileContextDeleteAct.setEnabled(False) self.fileContextRevertAct.setEnabled(False) self.fileContextDiffAct.setEnabled(False) self.fileContextPropsAct.setEnabled(False) return if pathStatus == self.NOT_UNDER_VCS: self.fileContextInfoAct.setEnabled(False) self.fileContextUpdateAct.setEnabled(False) self.fileContextAnnotateAct.setEnabled(False) self.fileContextLogAct.setEnabled(False) self.fileContextCommitAct.setEnabled(False) self.fileContextDeleteAct.setEnabled(False) self.fileContextRevertAct.setEnabled(False) self.fileContextDiffAct.setEnabled(False) self.fileContextPropsAct.setEnabled(False) upperDirStatus = self.getLocalStatus(os.path.dirname(path)) if upperDirStatus == self.NOT_UNDER_VCS: self.fileContextAddAct.setEnabled(False) else: self.fileContextAddAct.setEnabled(upperDirStatus != IND_ERROR and not debugMode) return self.fileContextInfoAct.setEnabled(True) self.fileContextUpdateAct.setEnabled(not debugMode) self.fileContextAnnotateAct.setEnabled(True) self.fileContextLogAct.setEnabled(True) self.fileContextAddAct.setEnabled(False) self.fileContextPropsAct.setEnabled(not debugMode) self.fileContextCommitAct.setEnabled(pathStatus in [ IND_ADDED, IND_DELETED, IND_MERGED, IND_MODIFIED_LR, IND_MODIFIED_L, IND_REPLACED, IND_CONFLICTED ] and not debugMode) self.fileContextDeleteAct.setEnabled(pathStatus != IND_DELETED and not debugMode) self.fileContextRevertAct.setEnabled(pathStatus != IND_UPTODATE and not debugMode) # Diff makes sense only for text files self.fileContextDiffAct.setEnabled(isFileSearchable(path))
def __init__(self, plugin, pathsToCommit, pathsToIgnore, parent=None): QDialog.__init__(self, parent) self.__plugin = plugin self.__createLayout(pathsToCommit, pathsToIgnore) self.setWindowTitle("SVN commit") # Fill the lists for item in pathsToCommit: newItem = QTreeWidgetItem(["", item[0], STATUS[item[1]]]) newItem.setCheckState(CHECK_COL, Qt.Checked) newItem.setToolTip(PATH_COL, item[0]) newItem.setToolTip(STATUS_COL, STATUS[item[1]]) self.__pathToCommitView.addTopLevelItem(newItem) diffButton = self.__createDiffButton() diffButton.path = item[0] diffButton.status = item[1] if os.path.isdir(item[0]) or item[1] in [IND_REPLACED] \ or not isFileSearchable(item[0]): diffButton.setEnabled(False) diffButton.setToolTip("Diff is not available") else: diffButton.setEnabled(True) diffButton.setToolTip("Click to see diff") self.__pathToCommitView.setItemWidget(newItem, DIFF_COL, diffButton) self.__resizeCommitPaths() self.__sortCommitPaths() for item in pathsToIgnore: newItem = QTreeWidgetItem([item[0], STATUS[item[1]]]) newItem.setToolTip(0, item[0]) newItem.setToolTip(1, STATUS[item[1]]) self.__pathToIgnoreView.addTopLevelItem(newItem) self.__pathToIgnoreView.header().resizeSections( QHeaderView.ResizeToContents) self.__updateSelectAllStatus() self.__updateOKStatus() self.__message.setFocus()
def __projectFiles(self, filters): """Project files list respecting the mask""" mainWindow = GlobalData().mainWindow files = [] for fname in GlobalData().project.filesList: if fname.endswith(sep): continue if self.__filterMatch(filters, fname): widget = mainWindow.getWidgetForFileName(fname) if widget is None: # Do not check for broken symlinks if isFileSearchable(fname, False): files.append(ItemToSearchIn(fname, "")) else: if widget.getType() in \ [MainWindowTabWidgetBase.PlainTextEditor]: files.append(ItemToSearchIn(fname, widget.getUUID())) QApplication.processEvents() if self.__cancelRequest: raise Exception("Cancel request") return files
def __projectFiles( self, filterRe ): " Project files list respecting the mask " mainWindow = GlobalData().mainWindow files = [] for fname in GlobalData().project.filesList: if fname.endswith( sep ): continue if filterRe is None or filterRe.match( fname ): widget = mainWindow.getWidgetForFileName( fname ) if widget is None: # Do not check for broken symlinks if isFileSearchable( fname, False ): files.append( ItemToSearchIn( fname, "" ) ) else: if widget.getType() in \ [ MainWindowTabWidgetBase.PlainTextEditor ]: files.append( ItemToSearchIn( fname, widget.getUUID() ) ) QApplication.processEvents() if self.__cancelRequest: raise Exception( "Cancel request" ) return files
def __dirFiles( self, path, filterRe, files ): " Files recursively for the dir " for item in os.listdir( path ): QApplication.processEvents() if self.__cancelRequest: raise Exception( "Cancel request" ) if os.path.isdir( path + item ): if item in [ ".svn", ".cvs" ]: # It does not make sense to search in revision control dirs continue anotherDir, isLoop = resolveLink( path + item ) if not isLoop: self.__dirFiles( anotherDir + sep, filterRe, files ) continue if not os.path.isfile( path + item ): continue realItem, isLoop = resolveLink( path + item ) if isLoop: continue if filterRe is None or filterRe.match( realItem ): found = False for itm in files: if itm.fileName == realItem: found = True break if not found: mainWindow = GlobalData().mainWindow widget = mainWindow.getWidgetForFileName( realItem ) if widget is None: if isFileSearchable( realItem ): files.append( ItemToSearchIn( realItem, "" ) ) else: if widget.getType() in \ [ MainWindowTabWidgetBase.PlainTextEditor ]: files.append( ItemToSearchIn( realItem, widget.getUUID() ) ) return
def __dirFiles(self, path, filterRe, files): " Files recursively for the dir " for item in os.listdir(path): QApplication.processEvents() if self.__cancelRequest: raise Exception("Cancel request") if os.path.isdir(path + item): if item in [".svn", ".cvs"]: # It does not make sense to search in revision control dirs continue anotherDir, isLoop = resolveLink(path + item) if not isLoop: self.__dirFiles(anotherDir + sep, filterRe, files) continue if not os.path.isfile(path + item): continue realItem, isLoop = resolveLink(path + item) if isLoop: continue if filterRe is None or filterRe.match(realItem): found = False for itm in files: if itm.fileName == realItem: found = True break if not found: mainWindow = GlobalData().mainWindow widget = mainWindow.getWidgetForFileName(realItem) if widget is None: if isFileSearchable(realItem): files.append(ItemToSearchIn(realItem, "")) else: if widget.getType() in \ [ MainWindowTabWidgetBase.PlainTextEditor ]: files.append( ItemToSearchIn(realItem, widget.getUUID())) return
def onBufferContextMenuAboutToshow(self): """Called when the plugin buffer context menu is about to show""" path = self.ide.currentEditorWidget.getFileName() debugMode = self.ide.mainWindow.debugMode if not os.path.isabs(path): self.bufContextInfoAct.setEnabled(False) self.bufContextUpdateAct.setEnabled(False) self.bufContextAnnotateAct.setEnabled(False) self.bufContextLogAct.setEnabled(False) self.bufContextAddAct.setEnabled(False) self.bufContextCommitAct.setEnabled(False) self.bufContextDeleteAct.setEnabled(False) self.bufContextRevertAct.setEnabled(False) self.bufContextDiffAct.setEnabled(False) self.bufContextPropsAct.setEnabled(False) return pathStatus = self.getLocalStatus(path) if pathStatus == IND_ERROR: self.bufContextInfoAct.setEnabled(False) self.bufContextUpdateAct.setEnabled(False) self.bufContextAnnotateAct.setEnabled(False) self.bufContextLogAct.setEnabled(False) self.bufContextAddAct.setEnabled(False) self.bufContextCommitAct.setEnabled(False) self.bufContextDeleteAct.setEnabled(False) self.bufContextRevertAct.setEnabled(False) self.bufContextDiffAct.setEnabled(False) self.bufContextPropsAct.setEnabled(False) return if pathStatus == self.NOT_UNDER_VCS: self.bufContextInfoAct.setEnabled(False) self.bufContextUpdateAct.setEnabled(False) self.bufContextAnnotateAct.setEnabled(False) self.bufContextLogAct.setEnabled(False) self.bufContextCommitAct.setEnabled(False) self.bufContextDeleteAct.setEnabled(False) self.bufContextRevertAct.setEnabled(False) self.bufContextDiffAct.setEnabled(False) self.bufContextPropsAct.setEnabled(False) upperDirStatus = self.getLocalStatus(os.path.dirname(path)) if upperDirStatus == self.NOT_UNDER_VCS: self.bufContextAddAct.setEnabled(False) else: self.bufContextAddAct.setEnabled(upperDirStatus != IND_ERROR and not debugMode) return self.bufContextInfoAct.setEnabled(True) self.bufContextUpdateAct.setEnabled(not debugMode) self.bufContextAddAct.setEnabled(False) self.bufContextPropsAct.setEnabled(not debugMode) self.bufContextDeleteAct.setEnabled(pathStatus != IND_DELETED and not debugMode) self.bufContextRevertAct.setEnabled(pathStatus != IND_UPTODATE and not debugMode) # Diff makes sense only for text files self.bufContextDiffAct.setEnabled(isFileSearchable(path)) widgetType = self.ide.currentEditorWidget.getType() if widgetType in [ MainWindowTabWidgetBase.PlainTextEditor, MainWindowTabWidgetBase.PythonGraphicsEditor ]: self.bufContextAnnotateAct.setEnabled(True) self.bufContextLogAct.setEnabled(True) else: self.bufContextAnnotateAct.setEnabled(False) self.bufContextLogAct.setEnabled(False) # Set the Commit... menu item status if pathStatus not in [ IND_ADDED, IND_DELETED, IND_MERGED, IND_MODIFIED_LR, IND_MODIFIED_L, IND_REPLACED, IND_CONFLICTED ]: self.bufContextCommitAct.setEnabled(False) else: if widgetType in [ MainWindowTabWidgetBase.PlainTextEditor, MainWindowTabWidgetBase.PythonGraphicsEditor ]: self.bufContextCommitAct.setEnabled( not self.ide.currentEditorWidget.isModified() and not debugMode) else: self.bufContextCommitAct.setEnabled(False)