def __onDel(self): """Triggered when a property del is clicked""" selected = list(self.__propsView.selectedItems()) if len(selected) == 0: self.__delButton.setEnabled(False) return name = str(selected[0].text(0)) res = QMessageBox.warning( self, "Deleting Property", "You are about to delete <b>" + name + "</b> SVN property from " + self.__path + ".\nAre you sure?", QMessageBox.StandardButtons(QMessageBox.Cancel | QMessageBox.Yes), QMessageBox.Cancel) if res != QMessageBox.Yes: return try: self.__client.propdel(name, self.__path) self.__populate() self.__plugin.notifyPathChanged(self.__path) self.__propsView.setFocus() except pysvn.ClientError as exc: message = exc.args[0] logging.error(message) except Exception as exc: logging.error(str(exc)) except: logging.error("Unknown property deleting error")
def __onReloadWithEncoding(self, act): """Triggered when encoding is selected""" # The method is called only for the existing disk files encoding = act.data() if self.__isSameEncodingAsCurrent(encoding): return if self.document().isModified(): res = QMessageBox.warning( self, 'Continue loosing changes', '<p>The buffer has unsaved changes. Are you sure to continue ' 'reloading the content using ' + encoding + ' encoding and ' 'loosing the changes?</p>', QMessageBox.StandardButtons(QMessageBox.Cancel | QMessageBox.Yes), QMessageBox.Cancel) if res == QMessageBox.Cancel: return # Do the reload fileName = self._parent.getFileName() setFileEncoding(fileName, encoding) self.__updateFilePosition() self.readFile(fileName) self.__restoreFilePosition() self.__updateMainWindowStatusBar()
def __svnDelete(self, path): res = QMessageBox.warning( None, "Deleting from SVN", "You are about to delete <b>" + path + "</b> from SVN and from the disk.\nAre you sure?", QMessageBox.StandardButtons(QMessageBox.Cancel | QMessageBox.Yes), QMessageBox.Cancel) if res != QMessageBox.Yes: return client = self.getSVNClient(self.getSettings()) pathList = [] def notifyCallback(event, paths=pathList): if event['path']: path = event['path'] if os.path.isdir(path) and not path.endswith(os.path.sep): path += os.path.sep action = notifyActionToString(event['action']) if action: logging.info(action + " " + path) paths.append(path) return try: client.callback_notify = notifyCallback client.remove(path) if pathList: logging.info("Finished") except Exception as excpt: logging.error(str(excpt)) for revertedPath in pathList: self.notifyPathChanged(revertedPath)
def __selectFile(self, extension): """Picks a file of a certain extension""" dialog = QFileDialog(self, 'Save flowchart as') dialog.setFileMode(QFileDialog.AnyFile) dialog.setLabelText(QFileDialog.Accept, "Save") dialog.setNameFilter(extension.upper() + " files (*." + extension.lower() + ")") urls = [] for dname in QDir.drives(): urls.append(QUrl.fromLocalFile(dname.absoluteFilePath())) urls.append(QUrl.fromLocalFile(QDir.homePath())) project = GlobalData().project if project.isLoaded(): urls.append(QUrl.fromLocalFile(project.getProjectDir())) dialog.setSidebarUrls(urls) suggestedFName = self.__parentWidget.getFileName() if '.' in suggestedFName: dotIndex = suggestedFName.rindex('.') suggestedFName = suggestedFName[:dotIndex] dialog.setDirectory(self.__getDefaultSaveDir()) dialog.selectFile(suggestedFName + "." + extension.lower()) dialog.setOption(QFileDialog.DontConfirmOverwrite, False) dialog.setOption(QFileDialog.DontUseNativeDialog, True) if dialog.exec_() != QDialog.Accepted: return None fileNames = dialog.selectedFiles() fileName = os.path.abspath(str(fileNames[0])) if os.path.isdir(fileName): logging.error("A file must be selected") return None if "." not in fileName: fileName += "." + extension.lower() # Check permissions to write into the file or to a directory if os.path.exists(fileName): # Check write permissions for the file if not os.access(fileName, os.W_OK): logging.error("There is no write permissions for " + fileName) return None else: # Check write permissions to the directory dirName = os.path.dirname(fileName) if not os.access(dirName, os.W_OK): logging.error("There is no write permissions for the " "directory " + dirName) return None if os.path.exists(fileName): res = QMessageBox.warning( self, "Save flowchart as", "<p>The file <b>" + fileName + "</b> already exists.</p>", QMessageBox.StandardButtons(QMessageBox.Abort | QMessageBox.Save), QMessageBox.Abort) if res == QMessageBox.Abort or res == QMessageBox.Cancel: return None # All prerequisites are checked, return a file name return fileName