예제 #1
0
 def __printPreviewImage(self):
     """
     Private slot to handle the Print Preview menu action.
     """
     from PyQt4.QtGui import QPrintPreviewDialog
     
     if self.mainWidget is None:
         KQMessageBox.critical(None,
             self.trUtf8("Print Preview"),
             self.trUtf8("""There is no UI file loaded."""))
         return
     
     settings = Preferences.Prefs.settings
     printer = KdeQt.KQPrinter.KQPrinter(mode = QPrinter.HighResolution)
     printer.setFullPage(True)
     
     if not KdeQt.isKDE():
         printer.setPrinterName(settings.value("UIPreviewer/printername").toString())
         printer.setPageSize(
             QPrinter.PageSize(settings.value("UIPreviewer/pagesize").toInt()[0]))
         printer.setPageOrder(
             QPrinter.PageOrder(settings.value("UIPreviewer/pageorder").toInt()[0]))
         printer.setOrientation(
             QPrinter.Orientation(settings.value("UIPreviewer/orientation").toInt()[0]))
         printer.setColorMode(
             QPrinter.ColorMode(settings.value("UIPreviewer/colormode").toInt()[0]))
     
     preview = QPrintPreviewDialog(printer, self)
     self.connect(preview, SIGNAL("paintRequested(QPrinter*)"), self.__print)
     preview.exec_()
예제 #2
0
 def __loadFile(self, fn):
     """
     Private slot to load a ui file.
     
     @param fn name of the ui file to be laoded (string or QString)
     """
     if self.mainWidget:
         self.mainWidget.close()
         self.previewSV.takeWidget()
         del self.mainWidget
         self.mainWidget = None
         
     # load the file
     try:
         self.mainWidget = uic.loadUi(fn)
     except:
         pass
     
     if self.mainWidget:
         self.currentFile = fn
         self.__updateChildren(self.styleCombo.currentText())
         if isinstance(self.mainWidget, QDialog) or \
            isinstance(self.mainWidget, QMainWindow):
             self.mainWidget.show()
             self.mainWidget.installEventFilter(self)
         else:
             self.previewSV.setWidget(self.mainWidget)
             self.mainWidget.show()
     else:
         KQMessageBox.warning(None,
             self.trUtf8("Load UI File"),
             self.trUtf8("""<p>The file <b>%1</b> could not be loaded.</p>""")\
                 .arg(fn))
     self.__updateActions()
예제 #3
0
    def __loadRules(self):
        """
        Private method to load the rules of the subscription.
        """
        fileName = self.rulesFileName()
        f = QFile(fileName)
        if f.exists():
            if not f.open(QIODevice.ReadOnly):
                KQMessageBox.warning(
                    None,
                    self.trUtf8("Load subscription rules"),
                    self.trUtf8("""Unable to open adblock file '%1' for reading.""").arg(fileName),
                )
            else:
                textStream = QTextStream(f)
                header = textStream.readLine(1024)
                if not header.startsWith("[Adblock"):
                    KQMessageBox.warning(
                        None,
                        self.trUtf8("Load subscription rules"),
                        self.trUtf8("""Adblock file '%1' does not start with [Adblock.""").arg(fileName),
                    )
                    f.close()
                    f.remove()
                    self.__lastUpdate = QDateTime()
                else:
                    self.__rules = []
                    while not textStream.atEnd():
                        line = textStream.readLine()
                        self.__rules.append(AdBlockRule(line))
                    self.__populateCache()
                    self.emit(SIGNAL("changed()"))

        if not self.__lastUpdate.isValid() or self.__lastUpdate.addDays(7) < QDateTime.currentDateTime():
            self.updateNow()
예제 #4
0
 def on_addInstalledApiFileButton_clicked(self):
     """
     Private slot to add an API file from the list of installed API files
     for the selected lexer language.
     """
     installedAPIFiles = self.__currentAPI.installedAPIFiles()
     if len(installedAPIFiles) > 0:
         installedAPIFilesPath = QFileInfo(installedAPIFiles[0]).path()
         installedAPIFilesShort = QStringList()
         for installedAPIFile in installedAPIFiles:
             installedAPIFilesShort.append(QFileInfo(installedAPIFile).fileName())
         file, ok = KQInputDialog.getItem(
             self,
             self.trUtf8("Add from installed APIs"),
             self.trUtf8("Select from the list of installed API files"),
             installedAPIFilesShort,
             0,
             False,
         )
         if ok:
             self.apiList.addItem(
                 Utilities.toNativeSeparators(QFileInfo(QDir(installedAPIFilesPath), file).absoluteFilePath())
             )
     else:
         KQMessageBox.warning(
             self,
             self.trUtf8("Add from installed APIs"),
             self.trUtf8("""There are no APIs installed yet.""" """ Selection is not available."""),
         )
         self.addInstalledApiFileButton.setEnabled(False)
 def on_renameButton_clicked(self):
     """
     Private slot to rename a custom toolbar.
     """
     oldName = self.toolbarComboBox.currentText()
     newName, ok = KQInputDialog.getText(\
         self,
         self.trUtf8("Rename Toolbar"),
         self.trUtf8("New Toolbar Name:"),
         QLineEdit.Normal,
         oldName)
     if ok and not newName.isEmpty():
         if oldName == newName:
             return
         if self.toolbarComboBox.findText(newName) != -1:
             # toolbar with this name already exists
             KQMessageBox.critical(self,
             self.trUtf8("Rename Toolbar"),
             self.trUtf8("""A toolbar with the name <b>%1</b> already exists.""")\
                 .arg(newName),
             QMessageBox.StandardButtons(\
                 QMessageBox.Abort))
             return
         index = self.toolbarComboBox.currentIndex()
         self.toolbarComboBox.setItemText(index, newName)
         tbItem = \
             self.__toolbarItems[self.toolbarComboBox.itemData(index).toULongLong()[0]]
         tbItem.title = newName
         tbItem.isChanged = True
예제 #6
0
 def startSynchronizedProcess(self, proc, program, arguments, workingDir = None):
     """
     Public method to start a synchroneous process
     
     This method starts a process and waits
     for its end while still serving the Qt event loop.
     
     @param proc process to start (QProcess)
     @param program path of the executable to start (string or QString)
     @param arguments list of arguments for the process (QStringList)
     @param workingDir working directory for the process (string or QString)
     @return flag indicating normal exit (boolean)
     """
     if proc is None:
         return
         
     if workingDir:
         proc.setWorkingDirectory(workingDir)
     proc.start(program, arguments)
     procStarted = proc.waitForStarted()
     if not procStarted:
         KQMessageBox.critical(None,
             self.trUtf8('Process Generation Error'),
             self.trUtf8(
                 'The process %1 could not be started. '
                 'Ensure, that it is in the search path.'
             ).arg(program))
         return False
     else:
         while proc.state() == QProcess.Running:
             QApplication.processEvents()
             QThread.msleep(300)
             QApplication.processEvents()
         return (proc.exitStatus() == QProcess.NormalExit) and (proc.exitCode() == 0)
 def on_newButton_clicked(self):
     """
     Private slot to create a new toolbar.
     """
     name, ok = KQInputDialog.getText(\
         self,
         self.trUtf8("New Toolbar"),
         self.trUtf8("Toolbar Name:"),
         QLineEdit.Normal)
     if ok and not name.isEmpty():
         if self.toolbarComboBox.findText(name) != -1:
             # toolbar with this name already exists
             KQMessageBox.critical(self,
             self.trUtf8("New Toolbar"),
             self.trUtf8("""A toolbar with the name <b>%1</b> already exists.""")\
                 .arg(name),
             QMessageBox.StandardButtons(\
                 QMessageBox.Abort))
             return
         
         tbItem = E4ToolBarItem(None, [], False)
         tbItem.title = name
         tbItem.isChanged = True
         self.__toolbarItems[id(tbItem)] = tbItem
         self.__toolBarItemToWidgetActionID[id(tbItem)] = []
         self.toolbarComboBox.addItem(name, QVariant(long(id(tbItem))))
         self.toolbarComboBox.model().sort(0)
         self.toolbarComboBox.setCurrentIndex(self.toolbarComboBox.findText(name))
 def __writeXMLMultiProject(self, fn = None):
     """
     Private method to write the multi project data to an XML file.
     
     @param fn the filename of the multi project file (string)
     """
     try:
         if fn.lower().endswith("e4mz"):
             try:
                 import gzip
             except ImportError:
                 KQMessageBox.critical(None,
                     self.trUtf8("Save multiproject file"),
                     self.trUtf8("""Compressed multiproject files not supported."""
                                 """ The compression library is missing."""))
                 return False
             f = gzip.open(fn, "wb")
         else:
             f = open(fn, "wb")
         
         MultiProjectWriter(self, f, os.path.splitext(os.path.basename(fn))[0])\
             .writeXML()
         
         f.close()
         
     except IOError:
         KQMessageBox.critical(None,
             self.trUtf8("Save multiproject file"),
             self.trUtf8("<p>The multiproject file <b>%1</b> could not be "
                 "written.</p>").arg(fn))
         return False
     
     return True
 def start(self, pfn, fn=None):
     """
     Public slot to start the calculation of the profile data.
     
     @param pfn basename of the profiling file (string)
     @param fn file to display the profiling data for (string)
     """
     self.basename = os.path.splitext(pfn)[0]
     
     fname = "%s.profile" % self.basename
     if not os.path.exists(fname):
         KQMessageBox.warning(None,
             self.trUtf8("Profile Results"),
             self.trUtf8("""<p>There is no profiling data"""
                         """ available for <b>%1</b>.</p>""")
                 .arg(pfn))
         self.close()
         return
     try:
         f = open(fname, 'rb')
         self.stats = pickle.load(f)
         f.close()
     except (EnvironmentError, pickle.PickleError, EOFError):
         KQMessageBox.critical(None,
             self.trUtf8("Loading Profiling Data"),
             self.trUtf8("""<p>The profiling data could not be"""
                         """ read from file <b>%1</b>.</p>""")
                 .arg(fname))
         self.close()
         return
     
     self.file = fn
     self.__populateLists()
     self.__finish()
예제 #10
0
 def __compileIDLDone(self, exitCode, exitStatus):
     """
     Private slot to handle the finished signal of the omniidl process.
     
     @param exitCode exit code of the process (integer)
     @param exitStatus exit status of the process (QProcess.ExitStatus)
     """
     self.compileRunning = False
     if exitStatus == QProcess.NormalExit and exitCode == 0:
         path = os.path.dirname(self.idlFile)
         poaList = glob.glob(os.path.join(path, "*__POA"))
         npoaList = [f.replace("__POA", "") for f in poaList]
         fileList = glob.glob(os.path.join(path, "*_idl.py"))
         for dir in poaList + npoaList:
             fileList += Utilities.direntries(dir, True, "*.py")
         for file in fileList:
             self.project.appendFile(file)
         if not self.noDialog:
             KQMessageBox.information(
                 None,
                 self.trUtf8("Interface Compilation"),
                 self.trUtf8("The compilation of the interface file was successful."),
             )
     else:
         if not self.noDialog:
             KQMessageBox.information(
                 None,
                 self.trUtf8("Interface Compilation"),
                 self.trUtf8("The compilation of the interface file failed."),
             )
     self.compileProc = None
 def __checkPluginsDownloadDirectory(self):
     """
     Private slot to check for the existance of the plugins download directory.
     """
     downloadDir = unicode(Preferences.getPluginManager("DownloadPath"))
     if not downloadDir:
         downloadDir = self.__defaultDownloadDir
     
     if not os.path.exists(downloadDir):
         try:
             os.mkdir(downloadDir, 0755)
         except (OSError, IOError), err:
             # try again with (possibly) new default
             downloadDir = self.__defaultDownloadDir
             if not os.path.exists(downloadDir):
                 try:
                     os.mkdir(downloadDir, 0755)
                 except (OSError, IOError), err:
                     KQMessageBox.critical(self.__ui,
                         self.trUtf8("Plugin Manager Error"),
                         self.trUtf8("""<p>The plugin download directory <b>%1</b> """
                                     """could not be created. Please configure it """
                                     """via the configuration dialog.</p>"""
                                     """<p>Reason: %2</p>""")\
                             .arg(downloadDir).arg(str(err)))
                     downloadDir = ""
 def on_namedReferenceButton_clicked(self):
     """
     Private slot to handle the named reference toolbutton.
     """
     # determine cursor position as length into text
     length = self.regexpTextEdit.textCursor().position()
     
     # only present group names that occur before the current cursor position
     regex = unicode(self.regexpTextEdit.toPlainText().left(length))
     names = self.namedGroups(regex)
     if not names:
         KQMessageBox.information(None,
             self.trUtf8("Named reference"),
             self.trUtf8("""No named groups have been defined yet."""))
         return
         
     qs = QStringList()
     for name in names:
         qs.append(name)
     groupName, ok = KQInputDialog.getItem(\
         None,
         self.trUtf8("Named reference"),
         self.trUtf8("Select group name:"),
         qs,
         0, True)
     if ok and not groupName.isEmpty():
         self.__insertString("(?P=%s)" % groupName)
 def __findDuplicates(self, cond, special, showMessage = False, index = QModelIndex()):
     """
     Private method to check, if an entry already exists.
     
     @param cond condition to check (string or QString)
     @param special special condition to check (string or QString)
     @param showMessage flag indicating a message should be shown,
         if a duplicate entry is found (boolean)
     @param index index that should not be considered duplicate (QModelIndex)
     @return flag indicating a duplicate entry (boolean)
     """
     cond = unicode(cond)
     special = unicode(special)
     idx = self.__model.getWatchPointIndex(cond, special)
     duplicate = idx.isValid() and idx.internalPointer() != index.internalPointer()
     if showMessage and duplicate:
         if not special:
             msg = self.trUtf8("""<p>A watch expression '<b>%1</b>'"""
                               """ already exists.</p>""")\
                     .arg(Utilities.html_encode(unicode(cond)))
         else:
             msg = self.trUtf8("""<p>A watch expression '<b>%1</b>'"""
                               """ for the variable <b>%2</b> already exists.</p>""")\
                     .arg(special)\
                     .arg(Utilities.html_encode(unicode(cond)))
         KQMessageBox.warning(None,
             self.trUtf8("Watch expression already exists"),
             msg)
     
     return duplicate
 def __init__(self, parent = None):
     """
     Constructor
     
     @param parent reference to the parent widget (QWidget)
     """
     QWidget.__init__(self, parent)
     self.setupUi(self)
     
     self.table.addAction(self.insertRowAction)
     self.table.addAction(self.deleteRowAction)
     
     if QSqlDatabase.drivers().isEmpty():
         KQMessageBox.information(None,
             self.trUtf8("No database drivers found"),
             self.trUtf8("""This tool requires at least one Qt database driver. """
             """Please check the Qt documentation how to build the """
             """Qt SQL plugins."""))
     
     self.connect(self.connections, SIGNAL("tableActivated(QString)"), 
                  self.on_connections_tableActivated)
     self.connect(self.connections, SIGNAL("schemaRequested(QString)"), 
                  self.on_connections_schemaRequested)
     self.connect(self.connections, SIGNAL("cleared()"), 
                  self.on_connections_cleared)
     
     self.emit(SIGNAL("statusMessage(QString)"), self.trUtf8("Ready"))
 def __importStyles(self, lexers):
     """
     Private method to import the styles of the given lexers.
     
     @param lexers dictionary of lexer objects for which to import the styles
     """
     fn = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Import Highlighting Styles"),
         QString(),
         self.trUtf8("eric4 highlighting styles file (*.e4h)"),
         None)
     
     if fn.isEmpty():
         return
     
     fn = unicode(fn)
     
     try:
         f = open(fn, "rb")
         try:
             line = f.readline()
             dtdLine = f.readline()
         finally:
             f.close()
     except IOError, err:
         KQMessageBox.critical(self,
             self.trUtf8("Import Highlighting Styles"),
             self.trUtf8("""<p>The highlighting styles could not be read"""
                         """ from file <b>%1</b>.</p><p>Reason: %2</p>""")\
                 .arg(fn)\
                 .arg(str(err))
         )
         return
예제 #16
0
def exportShortcuts(fn):
    """
    Module function to export the keyboard shortcuts for the defined QActions.
    
    @param fn filename of the export file (string)
    @return flag indicating success
    """
    try:
        if fn.lower().endswith("e4kz"):
            try:
                import gzip
            except ImportError:
                KQMessageBox.critical(None,
                    QApplication.translate("Shortcuts", "Export Keyboard Shortcuts"),
                    QApplication.translate("Shortcuts", 
                        """Compressed keyboard shortcut files"""
                        """ not supported. The compression library is missing."""))
                return 0
            f = gzip.open(fn, "wb")
        else:
            f = open(fn, "wb")
        
        ShortcutsWriter(f).writeXML()
        
        f.close()
        return True
    except IOError:
        return False
예제 #17
0
 def buildWidget(self):
     """
     Public slot to load a UI file.
     """
     if self.__widget:
         self.__widget.close()
         self.__layout.removeWidget(self.__widget)
         del self.__widget
         self.__widget = None
     
     try:
         self.__widget = uic.loadUi(self.__uiFileName)
     except:
         pass
     
     if not self.__widget:
         KQMessageBox.warning(None,
             self.trUtf8("Load UI File"),
             self.trUtf8("""<p>The file <b>%1</b> could not be loaded.</p>""")\
                 .arg(self.__uiFileName))
         self.__valid = False
         return
     
     self.__widget.setParent(self)
     self.__layout.addWidget(self.__widget)
     self.__widget.show()
     self.__valid = True
     self.adjustSize()
     
     self.__timer.stop()
 def __generateTSFileDone(self, exitCode, exitStatus):
     """
     Private slot to handle the finished signal of the pylupdate process.
     
     @param exitCode exit code of the process (integer)
     @param exitStatus exit status of the process (QProcess.ExitStatus)
     """
     if exitStatus == QProcess.NormalExit and exitCode == 0:
         KQMessageBox.information(None,
             self.trUtf8("Translation file generation"),
             self.trUtf8("The generation of the translation files (*.ts)"
                 " was successful."))
     else:
         KQMessageBox.critical(None,
             self.trUtf8("Translation file generation"),
             self.trUtf8("The generation of the translation files (*.ts) has failed."))
     
     proc = self.sender()
     for index in range(len(self.__pylupdateProcesses)):
         if proc == self.__pylupdateProcesses[index][0]:
             try:
                 os.remove(self.__pylupdateProcesses[index][1])
             except EnvironmentError:
                 pass
             del self.__pylupdateProcesses[index]
             break
     if not self.__pylupdateProcesses:
         # all done
         self.pylupdateProcRunning = False
예제 #19
0
 def add(self, transFileName, setTranslation = True):
     """
     Public method to add a translation to the list.
     
     If the translation file (*.qm) has not been loaded yet, it will
     be loaded automatically.
     
     @param transFileName name of the translation file to be added (string or QString)
     @param setTranslation flag indicating, if this should be set as the active
         translation (boolean)
     """
     fileName = QString(transFileName)
     if not self.__haveFileName(fileName):
         ntr = Translation()
         ntr.fileName = fileName
         ntr.name = self.__uniqueName(fileName)
         if ntr.name.isNull():
             KQMessageBox.warning(None,
                 self.trUtf8("Set Translator"),
                 self.trUtf8("""<p>The translation filename <b>%1</b>"""
                     """ is invalid.</p>""").arg(fileName))
             return
         
         ntr.translator = self.loadTransFile(fileName)
         if ntr.translator is None:
             return
         
         self.selector.addItem(ntr.name)
         self.translations.append(ntr)
     
     if setTranslation:
         tr = self.__findFileName(fileName)
         self.set(tr.name)
예제 #20
0
 def set(self, name):
     """
     Public slot to set a translator by name.
     
     @param name name (language) of the translator to set (string or QString)
     """
     name = QString(name)
     nTranslator = None
     
     if name.compare(noTranslationName) != 0:
         trans = self.__findName(name)
         if trans is None:
             KQMessageBox.warning(None,
                 self.trUtf8("Set Translator"),
                 self.trUtf8("""<p>The translator <b>%1</b> is not known.</p>""")\
                     .arg(name))
             return
             
         nTranslator = trans.translator
     
     if nTranslator == self.currentTranslator:
         return
     
     if self.currentTranslator is not None:
         QApplication.removeTranslator(self.currentTranslator)
     if nTranslator is not None:
         QApplication.installTranslator(nTranslator)
     self.currentTranslator = nTranslator
     
     self.selector.blockSignals(True)
     self.selector.setCurrentIndex(self.selector.findText(name))
     self.selector.blockSignals(False)
     
     self.emit(SIGNAL('translationChanged'))
 def findPrev(self):
     """
     Public slot to find the next previous of text.
     """
     if not self.havefound or self.ui.findtextCombo.currentText().isEmpty():
         self.show(self.viewmanager.textForFind())
         return
     
     self.__findBackwards = True
     txt = self.ui.findtextCombo.currentText()
     
     # This moves any previous occurrence of this statement to the head
     # of the list and updates the combobox
     self.findHistory.removeAll(txt)
     self.findHistory.prepend(txt)
     self.ui.findtextCombo.clear()
     self.ui.findtextCombo.addItems(self.findHistory)
     self.emit(SIGNAL('searchListChanged'))
     
     ok = self.__findNextPrev(txt, True)
     if ok:
         if self.replace:
             self.ui.replaceButton.setEnabled(True)
             self.ui.replaceSearchButton.setEnabled(True)
     else:
         KQMessageBox.information(self, self.windowTitle(),
             self.trUtf8("'%1' was not found.").arg(txt))
 def on_changeButton_clicked(self):
     """
     Private slot to change an entry.
     """
     row = self.groupsList.currentRow()
     if row < 0:
         return
     
     groupName = self.nameEdit.text()
     
     if groupName.isEmpty():
         KQMessageBox.critical(self,
             self.trUtf8("Add tool group entry"),
             self.trUtf8("You have to give a name for the group to add."))
         return
     
     if len(self.groupsList.findItems(groupName, Qt.MatchFlags(Qt.MatchExactly))):
         KQMessageBox.critical(self,
             self.trUtf8("Add tool group entry"),
             self.trUtf8("An entry for the group name %1 already exists.")\
                 .arg(groupName))
         return
         
     self.toolGroups[row][0] = unicode(groupName)
     self.groupsList.currentItem().setText(groupName)
 def on_saveButton_clicked(self):
     """
     Private slot to handle the Save button press.
     
     It saves the diff shown in the dialog to a file in the local
     filesystem.
     """
     if type(self.filename) is types.ListType:
         if len(self.filename) > 1:
             fname = self.vcs.splitPathList(self.filename)[0]
         else:
             dname, fname = self.vcs.splitPath(self.filename[0])
             if fname != '.':
                 fname = "%s.diff" % self.filename[0]
             else:
                 fname = dname
     else:
         fname = self.vcs.splitPath(self.filename)[0]
     
     selectedFilter = QString("")
     fname = KQFileDialog.getSaveFileName(\
         self,
         self.trUtf8("Save Diff"),
         fname,
         self.trUtf8("Patch Files (*.diff)"),
         selectedFilter,
         QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
     
     if fname.isEmpty():
         return
     
     ext = QFileInfo(fname).suffix()
     if ext.isEmpty():
         ex = selectedFilter.section('(*',1,1).section(')',0,0)
         if not ex.isEmpty():
             fname.append(ex)
     if QFileInfo(fname).exists():
         res = KQMessageBox.warning(self,
             self.trUtf8("Save Diff"),
             self.trUtf8("<p>The patch file <b>%1</b> already exists.</p>")
                 .arg(fname),
             QMessageBox.StandardButtons(\
                 QMessageBox.Abort | \
                 QMessageBox.Save),
             QMessageBox.Abort)
         if res != QMessageBox.Save:
             return
     fname = unicode(Utilities.toNativeSeparators(fname))
     
     try:
         f = open(fname, "wb")
         f.write(unicode(self.contents.toPlainText()))
         f.close()
     except IOError, why:
         KQMessageBox.critical(self, self.trUtf8('Save Diff'),
             self.trUtf8('<p>The patch file <b>%1</b> could not be saved.'
                 '<br>Reason: %2</p>')
                 .arg(unicode(fname)).arg(str(why)))
예제 #24
0
 def __about(self):
     """
     Private slot to show the about information.
     """
     KQMessageBox.about(self, self.trUtf8("TR Previewer"), self.trUtf8(
         """<h3> About TR Previewer </h3>"""
         """<p>The TR Previewer loads and displays Qt User-Interface files"""
         """ and translation files and shows dialogs for a selected language.</p>"""
     ))
예제 #25
0
    def startProcess(self, args, workingDir=None, setLanguage=False):
        """
        Public slot used to start the process.
        
        @param args list of arguments for the process (QStringList)
        @param workingDir working directory for the process (string or QString)
        @param setLanguage flag indicating to set the language to "C" (boolean)
        @return flag indicating a successful start of the process
        """
        self.errorGroup.hide()
        self.normal = False
        self.intercept = False

        self.__hasAddOrDelete = False

        self.proc = QProcess()
        if setLanguage:
            env = QProcessEnvironment.systemEnvironment()
            env.insert("LANG", "C")
            self.proc.setProcessEnvironment(env)
        nargs = QStringList()
        lastWasPwd = False
        for arg in args:
            if lastWasPwd:
                lastWasPwd = True
                continue
            nargs.append(arg)
            if arg == QString("--password"):
                lastWasPwd = True
                nargs.append("*****")

        self.resultbox.append(nargs.join(" "))
        self.resultbox.append("")

        self.connect(self.proc, SIGNAL("finished(int, QProcess::ExitStatus)"), self.__procFinished)
        self.connect(self.proc, SIGNAL("readyReadStandardOutput()"), self.__readStdout)
        self.connect(self.proc, SIGNAL("readyReadStandardError()"), self.__readStderr)

        if workingDir:
            self.proc.setWorkingDirectory(workingDir)
        self.proc.start("svn", args)
        procStarted = self.proc.waitForStarted()
        if not procStarted:
            self.buttonBox.setFocus()
            self.inputGroup.setEnabled(False)
            self.inputGroup.hide()
            KQMessageBox.critical(
                None,
                self.trUtf8("Process Generation Error"),
                self.trUtf8("The process %1 could not be started. " "Ensure, that it is in the search path.").arg(
                    "svn"
                ),
            )
        else:
            self.inputGroup.setEnabled(True)
            self.inputGroup.show()
        return procStarted
예제 #26
0
 def __about(self):
     """
     Private slot to show the about information.
     """
     KQMessageBox.about(self, self.trUtf8("UI Previewer"), self.trUtf8(
         """<h3> About UI Previewer </h3>"""
         """<p>The UI Previewer loads and displays Qt User-Interface files"""
         """ with various styles, which are selectable via a selection list.</p>"""
     ))
 def _selectEntries(self, local = True, filter = None):
     """
     Protected method to select entries based on their VCS status.
     
     @param local flag indicating local (i.e. non VCS controlled) file/directory
         entries should be selected (boolean)
     @param filter list of classes to check against
     """
     if self.project.vcs is None:
         return
     
     if local:
         compareString = QApplication.translate('ProjectBaseBrowser', "local")
     else:
         compareString = QString(self.project.vcs.vcsName())
     
     # expand all directories in order to iterate over all entries
     self._expandAllDirs()
     
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     QApplication.processEvents()
     self.selectionModel().clear()
     QApplication.processEvents()
     
     # now iterate over all entries
     startIndex = None
     endIndex = None
     selectedEntries = 0
     index = self.model().index(0, 0)
     while index.isValid():
         itm = self.model().item(index)
         if self.wantedItem(itm, filter) and \
            QString.compare(compareString, itm.data(1)) == 0:
             if startIndex is not None and \
                startIndex.parent() != index.parent():
                 self._setItemRangeSelected(startIndex, endIndex, True)
                 startIndex = None
             selectedEntries += 1
             if startIndex is None:
                 startIndex = index
             endIndex = index
         else:
             if startIndex is not None:
                 self._setItemRangeSelected(startIndex, endIndex, True)
                 startIndex = None
         index = self.indexBelow(index)
     if startIndex is not None:
         self._setItemRangeSelected(startIndex, endIndex, True)
     QApplication.restoreOverrideCursor()
     QApplication.processEvents()
     
     if selectedEntries == 0:
         KQMessageBox.information(None,
         QApplication.translate('ProjectBaseBrowser', "Select entries"),
         QApplication.translate('ProjectBaseBrowser', 
             """There were no matching entries found."""))
 def on_deleteButton_clicked(self):
     """
     Private slot to delete the selected search engines.
     """
     if self.enginesTable.model().rowCount() == 1:
         KQMessageBox.critical(self,
             self.trUtf8("Delete selected engines"),
             self.trUtf8("""You must have at least one search engine."""))
     
     self.enginesTable.removeSelected()
예제 #29
0
 def __about(self):
     """
     Private slot to show the about information.
     """
     KQMessageBox.about(self, self.trUtf8("SQL Browser"), self.trUtf8(
         """<h3>About SQL Browser</h3>"""
         """<p>The SQL browser window is a little tool to examine """
         """the data and the schema of a database and to execute """
         """queries on a database.</p>"""
     ))
예제 #30
0
 def __uiStartUp(self):
     """
     Private slot to do some actions after the UI has started and the main loop is up.
     """
     for warning in self.__warnings:
         KQMessageBox.warning(self,
             self.trUtf8("SQL Browser startup problem"),
             warning)
     
     if QSqlDatabase.connectionNames().isEmpty():
         self.__browser.addConnectionByDialog()