Beispiel #1
0
    void editMenuActivated(QAction *action)
    {
        QWidget* w = qApp->focusWidget();
        QTextEdit* te = qobject_cast<QTextEdit*>(w);
        QLineEdit* le = qobject_cast<QLineEdit*>(w);

        if (action == selectAction) {
            highlighting = this;
            return;
        }
        highlighting = 0;

        if (action == copyAction) {
            if (te) {
                if (te->hasEditFocus()) {
                    te->copy();
                } else {
                    QTextCursor c = te->textCursor();
                    te->selectAll();
                    te->copy();
                    te->setTextCursor(c);   // reset selection
                }
            } else if (le) {
                if (le->hasEditFocus()) {
                    le->copy();
                } else {
                    qApp->clipboard()->setText(le->text());
                }
            }
        } else if (action == pasteAction) {
            // assumes clipboard is not empty if 'Paste' is able to be
            // activated, otherwise the line/textedit might be cleared
            // without pasting anything back into it
            if (te) {
                if (!te->hasEditFocus())
                    te->clear();
                te->paste();
                if (!te->hasEditFocus()) {
                    te->moveCursor(QTextCursor::Start);
                    te->ensureCursorVisible();
                }
            } else if (le) {
                if (!le->hasEditFocus())
                    le->clear();
                le->paste();
                if (!le->hasEditFocus())
                    le->home(false);
            }
        }
    }
 /*!
    * \class TextCursorCopyText
  * \author Anders Fernström
  * \date 2006-02-07
    *
    * \brief Command for copying text
    */
 void TextCursorCopyText::execute()
 {
   Cell *cell = document()->getCursor()->currentCell();
   if( cell )
   {
     if( typeid(InputCell) == typeid(*cell) )
     {
       InputCell *inputcell = dynamic_cast<InputCell*>(cell);
       if( inputcell->textEditOutput()->hasFocus() &&
         inputcell->isEvaluated() )
       {
         inputcell->textEditOutput()->copy();
       }
       else
         inputcell->textEdit()->copy();
     }
     else if( typeid(GraphCell) == typeid(*cell) )
     {
       GraphCell *graphcell = dynamic_cast<GraphCell*>(cell);
       if( graphcell->textEditOutput()->hasFocus() &&
         graphcell->isEvaluated() )
       {
         graphcell->textEditOutput()->copy();
       }
       else
         graphcell->textEdit()->copy();
     }
     else if( typeid(LatexCell) == typeid(*cell) )
     {
       LatexCell *latexcell = dynamic_cast<LatexCell*>(cell);
       if( latexcell->textEditOutput()->hasFocus() &&
         latexcell->isEvaluated() )
       {
         latexcell->textEditOutput()->copy();
       }
       else
         latexcell->textEdit()->copy();
     }
     else
     {
       QTextEdit *editor = cell->textEdit();
       if( editor )
       {
         editor->copy();
       }
     }
   }
 }
Beispiel #3
0
void CBaseEditWindow::copy( void )
{
	QTextEdit* doc = activeDocument();
	if( doc != NULL ) { doc->copy(); }
}
Beispiel #4
0
// コピー
void MainWindow::textEditCopy() {
    QTextEdit* textEdit = getCurrentTextEdit();
    if (textEdit == NULL) return;
    textEdit->copy();
}