Exemplo n.º 1
0
 def copy(self):
     """Copy text to clipboard... or keyboard interrupt"""
     if self.hasSelectedText():
         text = self.selectedText()
         text = text.replace('>>> ', '').replace('... ', '').strip()  # removing prompts
         QApplication.clipboard().setText(text)
     else:
         raise KeyboardInterrupt
Exemplo n.º 2
0
 def copy(self):
     """Copy text to clipboard... or keyboard interrupt"""
     if self.hasSelectedText():
         text = self.selectedText()
         text = text.replace('>>> ',
                             '').replace('... ',
                                         '').strip()  # removing prompts
         QApplication.clipboard().setText(text)
     else:
         raise KeyboardInterrupt
Exemplo n.º 3
0
    def copySelectedResults(self):
        if len(self.selectedIndexes()) <= 0:
            return
        model = self.model()

        # convert to string using tab as separator
        text = model.headerToString("\t")
        for idx in self.selectionModel().selectedRows():
            text += "\n" + model.rowToString(idx.row(), "\t")

        QApplication.clipboard().setText(text, QClipboard.Selection)
        QApplication.clipboard().setText(text, QClipboard.Clipboard)
Exemplo n.º 4
0
    def copySelectedResults(self):
        if len(self.viewResult.selectedIndexes()) <= 0:
            return
        model = self.viewResult.model()

        # convert to string using tab as separator
        text = model.headerToString("\t")
        for idx in self.viewResult.selectionModel().selectedRows():
            text += "\n" + model.rowToString(idx.row(), "\t")

        QApplication.clipboard().setText(text, QClipboard.Selection)
        QApplication.clipboard().setText(text, QClipboard.Clipboard)
Exemplo n.º 5
0
 def contextMenuEvent(self, e):
     menu = QMenu(self)
     subMenu = QMenu(menu)
     titleHistoryMenu = QCoreApplication.translate("PythonConsole", "Command History")
     subMenu.setTitle(titleHistoryMenu)
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Show"),
         self.showHistory, 'Ctrl+Shift+SPACE')
     subMenu.addSeparator()
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Save"),
         self.writeHistoryFile)
     subMenu.addSeparator()
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Clear File"),
         self.clearHistory)
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Clear Session"),
         self.clearHistorySession)
     menu.addMenu(subMenu)
     menu.addSeparator()
     copyAction = menu.addAction(
         QCoreApplication.translate("PythonConsole", "Copy"),
         self.copy, QKeySequence.Copy)
     pasteAction = menu.addAction(
         QCoreApplication.translate("PythonConsole", "Paste"),
         self.paste, QKeySequence.Paste)
     copyAction.setEnabled(False)
     pasteAction.setEnabled(False)
     if self.hasSelectedText():
         copyAction.setEnabled(True)
     if QApplication.clipboard().text():
         pasteAction.setEnabled(True)
     menu.exec_(self.mapToGlobal(e.pos()))
Exemplo n.º 6
0
 def doCopyAll(self):
     output = ''
     for r in range(self.rasterInfoList.count()):
         output += self.rasterInfoList.item(r).text() + "\n"
     if output:
         clipboard = QApplication.clipboard()
         clipboard.setText(output)
Exemplo n.º 7
0
 def doCopyLine(self):
     output = ''
     items = self.rasterInfoList.selectedItems()
     for r in items:
         output += r.text() + "\n"
     if output:
         clipboard = QApplication.clipboard()
         clipboard.setText(output)
Exemplo n.º 8
0
 def keyPressEvent(self, e):
     if (e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier) and e.key() == Qt.Key_C:
         items = ''
         for r in range(self.rasterInfoList.count()):
             items.append(self.rasterInfoList.item(r).text() + "\n")
         if items:
             clipboard = QApplication.clipboard()
             clipboard.setText(items)
     else:
         QWidget.keyPressEvent(self, e)
Exemplo n.º 9
0
    def paste(self):
        """
        Method to display data from the clipboard.

        XXX: It should reimplement the virtual QScintilla.paste method,
        but it seems not used by QScintilla code.
        """
        stringPaste = unicode(QApplication.clipboard().text())
        if self.is_cursor_on_last_line():
            if self.hasSelectedText():
                self.removeSelectedText()
        else:
            self.move_cursor_to_end()
        self.insertFromDropPaste(stringPaste)
Exemplo n.º 10
0
 def mousePressEvent(self, e):
     """
     Re-implemented to handle the mouse press event.
     e: the mouse press event (QMouseEvent)
     """
     self.setFocus()
     if e.button() == Qt.MidButton:
         stringSel = unicode(QApplication.clipboard().text(QClipboard.Selection))
         if not self.is_cursor_on_last_line():
             self.move_cursor_to_end()
         self.insertFromDropPaste(stringSel)
         e.accept()
     else:
         QsciScintilla.mousePressEvent(self, e)