Exemplo n.º 1
0
 QString CompleterTextEditWidget::validTextUnderCursor() const
 {
     QTextCursor tc = textCursor();
     QTextCursor t1=tc;
     t1.select(QTextCursor::WordUnderCursor);
     QString w=t1.selectedText().trimmed();
     //std::cout<<"sel "<<w.toAscii().data()<<std::endl;
     QString cutl("1234567890*+!-?&!§$%&/()=?}][{\\~#'.:,;<>^");
     QString cutlb("*+!-?&!§$%&/()=?}][{\\~#'.:,;<>^");
     while (w.size()>0 && cutl.contains(w[0])) {
         w=w.remove(0,1);
         //std::cout<<"rf  "<<w.toAscii().data()<<std::endl;
     }
     while (w.size()>0 && cutlb.contains(w[w.size()-1])) {
         w=w.remove(w.size()-1,1);
         //std::cout<<"rb  "<<w.toAscii().data()<<std::endl;
     }
     int bn=tc.blockNumber();
     while (tc.blockNumber()==bn && !validwords.contains(w) &&  tc.position()>0) {
        if (!tc.movePosition(QTextCursor::Left)) break;
        t1=tc;
        t1.select(QTextCursor::WordUnderCursor);
        w=t1.selectedText().trimmed();
        //std::cout<<w.toAscii().data()<<std::endl;
         while (w.size()>0 && cutl.contains(w[0])) {
             w=w.remove(0,1);
             //std::cout<<"rf  "<<w.toAscii().data()<<std::endl;
         }
         while (w.size()>0 && cutlb.contains(w[w.size()-1])) {
             w=w.remove(w.size()-1,1);
             //std::cout<<"rb  "<<w.toAscii().data()<<std::endl;
         }
     }
     if (validwords.contains(w)) return w;
     else return "";
 }
Exemplo n.º 2
0
void CompleterTextEditWidget::uncomment(){
    QTextCursor c(textCursor());
    if (c.selectionStart() == c.selectionEnd()) {
        c.select(QTextCursor::LineUnderCursor);
        c.insertText(removeComments(c.selectedText()));
        //setTextCursor(c);
    } else {
        // now we have to iterate through all selected blocks (lines) and indent them
        QTextCursor c1(c);
        c1.setPosition(c.selectionStart());
        QTextCursor c2(c);
        c2.setPosition(c.selectionEnd());
        c1.beginEditBlock();
        while (c1.blockNumber() <= c2.blockNumber()) {
            c1.select(QTextCursor::BlockUnderCursor);
            //std::cout<<"'"<<c1.selectedText().toAscii().data()<<"'  =>  '"<<removeComments(c1.selectedText()).toAscii().data()<<"'"<<std::endl;
            c1.insertText(removeComments(c1.selectedText()));
            if (!c1.movePosition(QTextCursor::NextBlock))
                break;
        }
        c1.endEditBlock();
        setTextCursor(c);
    }
}
Exemplo n.º 3
0
bool CodeEditor::findNext( const QString &findText,bool cased,bool wrap ){

    QTextDocument::FindFlags flags=0;
    if( cased ) flags|=QTextDocument::FindCaseSensitively;

    setCenterOnScroll( true );

    bool found=find( findText,flags );

    if( !found && wrap ){

        QTextCursor cursor=textCursor();

        setTextCursor( QTextCursor( document() ) );

        found=find( findText,flags );

        if( !found ) setTextCursor( cursor );
    }

    setCenterOnScroll( false );

    return found;
}
Exemplo n.º 4
0
void GroupedLineEdit::selectAll()
{
	QTextCursor c = textCursor();
	c.select(QTextCursor::LineUnderCursor);
	setTextCursor(c);
}
Exemplo n.º 5
0
//! [5]
QString ContactListEdit::textUnderCursor() const
{
    QTextCursor tc = textCursor();
    tc.select(QTextCursor::WordUnderCursor);
    return tc.selectedText();
}
Exemplo n.º 6
0
 * Nothing is done on mismatch.
 */
unsigned int ChatbarTextEdit::completeAtCursor() {
	// Get an alphabetically sorted list of usernames
	unsigned int id = 0;

	QList<QString> qlsUsernames;

	if (ClientUser::c_qmUsers.empty()) return id;
	foreach(ClientUser *usr, ClientUser::c_qmUsers) {
		qlsUsernames.append(usr->qsName);
	}
	qSort(qlsUsernames);

	QString target = QString();
	QTextCursor tc = textCursor();

	if (toPlainText().isEmpty() || tc.position() == 0) {
		target = qlsUsernames.first();
		tc.insertText(target);
	} else {
		bool bBaseIsName = false;
		int iend = tc.position();
		int istart = toPlainText().lastIndexOf(QLatin1Char(' '), iend - 1) + 1;
		QString base = toPlainText().mid(istart, iend - istart);
		tc.setPosition(istart);
		tc.setPosition(iend, QTextCursor::KeepAnchor);

		if (qlsUsernames.last() == base) {
			bBaseIsName = true;
			target = qlsUsernames.first();
Exemplo n.º 7
0
QString LiteEditorWidget::wordUnderCursor() const
{
    QTextCursor tc = textCursor();
    tc.select(QTextCursor::WordUnderCursor);
    return tc.selectedText();
}
Exemplo n.º 8
0
bool SourceViewerWidget::findText(const QString &text, WebWidget::FindFlags flags)
{
	const bool isTheSame(text == m_findText);

	m_findText = text;
	m_findFlags = flags;

	if (!text.isEmpty())
	{
		QTextDocument::FindFlags nativeFlags;

		if (flags.testFlag(WebWidget::BackwardFind))
		{
			nativeFlags |= QTextDocument::FindBackward;
		}

		if (flags.testFlag(WebWidget::CaseSensitiveFind))
		{
			nativeFlags |= QTextDocument::FindCaseSensitively;
		}

		QTextCursor findTextCursor(m_findTextAnchor);

		if (!isTheSame)
		{
			findTextCursor = textCursor();
		}
		else if (!flags.testFlag(WebWidget::BackwardFind))
		{
			findTextCursor.setPosition(findTextCursor.selectionEnd(), QTextCursor::MoveAnchor);
		}

		m_findTextAnchor = document()->find(text, findTextCursor, nativeFlags);

		if (m_findTextAnchor.isNull())
		{
			m_findTextAnchor = textCursor();
			m_findTextAnchor.setPosition((flags.testFlag(WebWidget::BackwardFind) ? (document()->characterCount() - 1) : 0), QTextCursor::MoveAnchor);
			m_findTextAnchor = document()->find(text, m_findTextAnchor, nativeFlags);
		}

		if (!m_findTextAnchor.isNull())
		{
			const QTextCursor currentTextCursor(textCursor());

			disconnect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateTextCursor()));

			setTextCursor(m_findTextAnchor);
			ensureCursorVisible();

			const QPoint position(horizontalScrollBar()->value(), verticalScrollBar()->value());

			setTextCursor(currentTextCursor);

			horizontalScrollBar()->setValue(position.x());
			verticalScrollBar()->setValue(position.y());

			connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateTextCursor()));
		}
	}

	m_findTextSelection = m_findTextAnchor;

	updateSelection();

	return !m_findTextAnchor.isNull();
}
Exemplo n.º 9
0
void GenericCodeEditor::paintLineIndicator( QPaintEvent *e )
{
    QPalette plt( mLineIndicator->palette() );
    QRect r( e->rect() );
    QPainter p( mLineIndicator );

    p.fillRect( r, plt.color( QPalette::Mid ) );

    QTextDocument *doc = QPlainTextEdit::document();
    QTextCursor cursor(textCursor());
    int selStartBlock, selEndBlock;
    if (cursor.hasSelection()) {
        selStartBlock = doc->findBlock(cursor.selectionStart()).blockNumber();
        selEndBlock = doc->findBlock(cursor.selectionEnd()).blockNumber();
    }
    else
        selStartBlock = selEndBlock = -1;

    QTextBlock block = firstVisibleBlock();
    int blockNumber = block.blockNumber();
    qreal top = blockBoundingGeometry(block).translated(contentOffset()).top();
    qreal bottom = top + blockBoundingRect(block).height();

    while (block.isValid() && top <= e->rect().bottom()) {
        if (block.isVisible() && bottom >= e->rect().top()) {
            p.save();

            QRectF numRect( 0, top, mLineIndicator->width() - 1, bottom - top );

            int num = blockNumber;
            if (num >= selStartBlock && num <= selEndBlock) {
                num -= selStartBlock;
                p.setPen(Qt::NoPen);
                p.setBrush(plt.color(QPalette::Highlight));
                p.drawRect(numRect);
                p.setPen(plt.color(QPalette::HighlightedText));
            }

            QString number = QString::number(num + 1);
            p.setPen(plt.color(QPalette::ButtonText));
            p.drawText(0, top, mLineIndicator->width() - 10, bottom - top,
                       Qt::AlignRight, number);

            p.restore();
        }

        block = block.next();
        top = bottom;
        bottom = top + blockBoundingRect(block).height();
        ++blockNumber;
    }
    
    if(!mEditorBoxIsActive) {
        QColor color = plt.color(QPalette::Mid);
        if(color.lightness() >= 128)
            color = color.darker(60);
        else
            color = color.lighter(50);
        
        color.setAlpha(inactiveFadeAlpha());
        p.fillRect( r, color );
    }
}
Exemplo n.º 10
0
void QSAEditor::doObjectCompletion()
{
    QTextCursor cursor = textCursor();
    cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
    QString objectName = cursor.selectedText();
    if (objectName.endsWith(QLatin1Char('-')))
        objectName.chop(1);

    objectName = objectName.simplified();

    QString object = resolveFullyQualifiedValue(objectName, parseAssignments(functionCode()));

    bool assumedStatic = false;
    QSCompletionObject o;
    if(objectName == object) {
        QSObject stobj = env()->globalObject().get(object);
        if(stobj.isValid() && stobj.objectType()->valueType() == TypeClass) {
#if defined ( QSA_COMPLETION_DEBUG )
            printf(" -> assuming static\n");
#endif
            o = stobj;
            assumedStatic = true;
        }
    }
    if(o.type == QSCompletionObject::TNull) {
        o = queryObject(object);
    }

#if defined ( QSA_COMPLETION_DEBUG )
    printf(" -> type is: %d\n", o.type);
#endif

    o.resolve();
    if (o.isNull())
        return;

    QVector<CompletionEntry> res;

    QSObject nullObject;
    switch (o.type) {
    case QSCompletionObject::TQSObject:
#if defined ( QSA_COMPLETION_DEBUG )
        printf(" -> objectType is: %s\n", o.qsobj.objectType()->name().latin1());
#endif
        if(o.qsobj.objectType()->name() == QString::fromLatin1("FactoryObject")){
            QSObject sinst = ( (QSFactoryObjectProxy*) o.qsobj.objectType() )->staticInstance();
            if(!sinst.isValid())
                return;
            QSWrapperShared *shared = (QSWrapperShared*) sinst.shVal();
            completeQObject( shared->objects, object, res );
            break;
        }
        completeQSObject(o.qsobj, res, !assumedStatic);
        break;
    case QSCompletionObject::TQMetaObject:
        completeQMetaObject(o.meta, object, res, IncludeSuperClass, nullObject);
        break;
    case QSCompletionObject::TQObject:
        completeQObject(o.qobj, object, res);
        break;
    case QSCompletionObject::TNull:
        break;
    }

    if (!res.isEmpty()) {
        QFrame *f = new QFrame(0, Qt::Popup);
        f->setAttribute(Qt::WA_DeleteOnClose);

        QWidget *box = new CompletionBox(this, res);

        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(box);
        layout->setMargin(0);
        f->setLayout(layout);

        f->move(mapToGlobal(cursorRect().bottomLeft()));
        f->show();
        box->setFocus();
    }
}
Exemplo n.º 11
0
bool Console::inCommandLine() const
{
    return document()->blockCount()-1 == textCursor().blockNumber() && textCursor().positionInBlock() >= m_prefix.length();
}
Exemplo n.º 12
0
QString Console::currentWord() const
{
    QTextCursor cur = textCursor();
    cur.select(QTextCursor::WordUnderCursor);
    return cur.selectedText();
}
Exemplo n.º 13
0
void Console::keyPressEvent(QKeyEvent *event)
{
    if (event->key() == Qt::Key_Return) // process command
    {
        if (m_completer && m_completer->popup()->isVisible()) {
            event->ignore();
            return;
        } else {
            processCommand();
        }
        return;
    }

  if (inCommandLine())
  {
    // clear selection that spans multiple blocks (or prefix characters) (would overwrite previous command lines):
    QTextCursor cur = textCursor();
    if (cur.hasSelection())
    {
      if (document()->findBlock(cur.selectionStart()) != document()->findBlock(cur.selectionEnd()) || // spans multiple blocks (including command line)
          cur.selectionStart()-cur.block().position() < m_prefix.length() || // spans prefix
          cur.selectionEnd()-cur.block().position() < m_prefix.length() ) // spans prefix
      {
        cur.clearSelection();
        if (cur.positionInBlock() < m_prefix.length())
          cur.setPosition(cur.block().position()+m_prefix.length());
        setTextCursor(cur);
      }
    }
    if (cur.positionInBlock() == m_prefix.length())
    {
      cur.setCharFormat(QTextCharFormat()); // make sure we don't pick up format from prefix
      setTextCursor(cur);
    }
    // react to keystroke:
    if (event->matches(QKeySequence::MoveToPreviousLine)) // history up
    {

      if (m_history.isEmpty() || m_historyPos >= m_history.size()-1)
        return;
      ++m_historyPos;
      int index = m_history.size()-m_historyPos-1;
      QTextCursor cur(document()->lastBlock());
      cur.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, m_prefix.length());
      cur.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
      cur.removeSelectedText();
      cur.setCharFormat(QTextCharFormat());
      cur.insertText(m_history.at(index));
      setTextCursor(cur);

    } else if (event->matches(QKeySequence::MoveToNextLine)) // history down
    {

      if (m_history.isEmpty() || m_historyPos <= 0)
        return;
      --m_historyPos;
      int index = m_history.size()-m_historyPos-1;
      QTextCursor cur(document()->lastBlock());
      cur.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, m_prefix.length());
      cur.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
      cur.removeSelectedText();
      cur.setCharFormat(QTextCharFormat());
      cur.insertText(m_history.at(index));
      setTextCursor(cur);
    } else if (event->matches(QKeySequence::Paste)) // paste text, do it manually to remove text char formatting and newlines
    {
      QString pasteText = QApplication::clipboard()->text();
      pasteText.replace("\n", "").replace("\r", "");
      cur.setCharFormat(QTextCharFormat());
      cur.insertText(pasteText);
      setTextCursor(cur);
    } else if (event->key() == Qt::Key_Backspace || event->matches(QKeySequence::MoveToPreviousChar)) // only allow backspace if we wouldn't delete last char of prefix, similar left arrow
    {
      if (cur.positionInBlock() > m_prefix.length())
        QPlainTextEdit::keyPressEvent(event);
    } else if (event->matches(QKeySequence::MoveToStartOfLine) || event->key() == Qt::Key_Home) {
        // Don't move past prefix when pressing home
        // OSX treats the home key as MoveToStartOfDocument, so including the key code here too
        cur.movePosition(QTextCursor::PreviousCharacter,
                         event->modifiers() & Qt::ShiftModifier ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor,
                         cur.positionInBlock() - m_prefix.length());
        cur.setCharFormat(QTextCharFormat());
        setTextCursor(cur);
    } else if (event->key() == Qt::Key_Escape) {
        if (m_completer && m_completer->popup()->isVisible()) {
            m_completer->popup()->hide();
        } else {
            QTextCursor cur(document()->lastBlock());
            cur.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, m_prefix.length());
            cur.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
            cur.removeSelectedText();
            setTextCursor(cur);
        }
    } else if (event->key() == Qt::Key_Tab) {
        if (m_completer) {
            m_completer->setCompletionPrefix(currentWord());
            QRect cr = cursorRect();
            cr.setWidth(m_completer->popup()->sizeHintForColumn(0)
                        + m_completer->popup()->verticalScrollBar()->sizeHint().width());
            m_completer->complete(cr);
        }
    } else if (!event->matches(QKeySequence::Close) &&
               !event->matches(QKeySequence::New) &&
               !event->matches(QKeySequence::Open) &&
               !event->matches(QKeySequence::Preferences) &&
               !event->matches(QKeySequence::Bold) &&
               !event->matches(QKeySequence::Italic) &&
               !event->matches(QKeySequence::InsertLineSeparator) &&
               !event->matches(QKeySequence::InsertParagraphSeparator) &&
               !event->matches(QKeySequence::Redo) &&
               !event->matches(QKeySequence::Undo) &&
               !event->matches(QKeySequence::DeleteStartOfWord))
    {
      QPlainTextEdit::keyPressEvent(event);
    }
  } else // cursor position not in command line
  {
    if (event->matches(QKeySequence::MoveToEndOfDocument) ||
        event->matches(QKeySequence::MoveToEndOfBlock) ||
        event->matches(QKeySequence::MoveToEndOfLine) ||
        event->matches(QKeySequence::MoveToStartOfDocument) ||
        event->matches(QKeySequence::MoveToStartOfBlock) ||
        event->matches(QKeySequence::MoveToStartOfLine) ||
        //event->matches(QKeySequence::MoveToNextLine) ||
        event->matches(QKeySequence::MoveToNextWord) ||
        event->matches(QKeySequence::MoveToNextChar) ||
        //event->matches(QKeySequence::MoveToPreviousLine) ||
        event->matches(QKeySequence::MoveToPreviousWord) ||
        event->matches(QKeySequence::MoveToPreviousChar) ||
        event->matches(QKeySequence::SelectAll) ||
        event->matches(QKeySequence::SelectEndOfDocument) ||
        event->matches(QKeySequence::SelectEndOfBlock) ||
        event->matches(QKeySequence::SelectEndOfLine) ||
        event->matches(QKeySequence::SelectStartOfDocument) ||
        event->matches(QKeySequence::SelectStartOfBlock) ||
        event->matches(QKeySequence::SelectStartOfLine) ||
        event->matches(QKeySequence::SelectNextLine) ||
        event->matches(QKeySequence::SelectNextWord) ||
        event->matches(QKeySequence::SelectNextChar) ||
        event->matches(QKeySequence::SelectPreviousLine) ||
        event->matches(QKeySequence::SelectPreviousWord) ||
        event->matches(QKeySequence::SelectPreviousChar) ||
        event->matches(QKeySequence::Copy) ||
           event->key() == Qt::Key_Shift ||
           event->key() == Qt::Key_Alt ||
           event->key() == Qt::Key_Control ||
           event->key() == Qt::Key_Meta
       )
    {


        QPlainTextEdit::keyPressEvent(event);
    } else {
        // Place cursor in command line
        moveToEndOfCommandLine();
        QPlainTextEdit::keyPressEvent(event);
    }
  }
}
Exemplo n.º 14
0
bool ChatTextEdit::eventFilter(QObject *obj, QEvent *event)
{
    if (event->type() == QEvent::KeyPress)
    {
        QKeyEvent *keyEvent = (QKeyEvent *) event;

        if (keyEvent->key() == Qt::Key_Up)
        {
            // Key up
            QTextCursor cursor = textCursor();
            int pos = cursor.position();
            bool sel = keyEvent->modifiers() == Qt::ShiftModifier;
            cursor.movePosition(QTextCursor::Up, (sel ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor));

            if (pos == cursor.position())
                cursor.movePosition(QTextCursor::Start, (sel ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor));

            setTextCursor(cursor);

            return true;
        }
        else  if (keyEvent->key() == Qt::Key_Down)
        {
            // Key down
            QTextCursor cursor = textCursor();
            int pos = cursor.position();
            bool sel = keyEvent->modifiers() == Qt::ShiftModifier;
            cursor.movePosition(QTextCursor::Down, (sel ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor));

            if (pos == cursor.position())
                cursor.movePosition(QTextCursor::End, (sel ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor));

            setTextCursor(cursor);
            return true;
        }
        else if (keyEvent->nativeScanCode() == 36)
        {
            // Return pressed
            if (Client::enterIsSend && !(keyEvent->modifiers() & Qt::ShiftModifier))
            {
                isComposing = false;
                emit returnPressed();
                return true;
            }
        }
        else if (keyEvent->nativeScanCode() == 54 &&
                 keyEvent->modifiers() == Qt::ControlModifier)
        {
            // Copy
            QTextCursor cursor = textCursor();
            if (cursor.hasSelection())
            {
                QTextDocumentFragment selection = cursor.selection();
                QClipboard *clipboard = QApplication::clipboard();
                clipboard->setText(Utilities::htmlToWAText(selection.toHtml()));

                QMaemo5InformationBox::information(this,"Copied");
                return true;
            }
        }
        else if (keyEvent->nativeScanCode() == 55 &&
                 keyEvent->modifiers() == Qt::ControlModifier)
        {
            // Paste event
            QTextCursor cursor = textCursor();
            QClipboard *clipboard = QApplication::clipboard();

            cursor.insertHtml(Utilities::WATextToHtml(clipboard->text(),32,false));

            return true;
        }
        else if (!isComposing)
        {
            isComposing = true;
            emit composing();
        }
        else
        {
            lastKeyPressed = QDateTime::currentMSecsSinceEpoch();
            composingTimer.start(2000);
        }
    }
    else if (event->type() == QEvent::InputMethod)
    {
        QInputMethodEvent *inputEvent = (QInputMethodEvent *) event;

        //Utilities::logData("Commit String: '" + inputEvent->commitString() + "'");
        if (inputEvent->commitString() == "\n" && Client::enterIsSend)
        {
            // Let's hide the keyboard if it was shown
            QTimer::singleShot(0,this,SLOT(closeKB()));
            isComposing = false;
            emit returnPressed();
            return true;
        }
    }

    return QTextEdit::eventFilter(obj,event);
}
Exemplo n.º 15
0
bool QFCompleterTextEditWidget::replaceFirst(QString phrase, QString replaceBy, bool searchFromStart, bool matchCase, bool wholeWords, bool replaceAll, bool askBeforeReplace){
    this->searchFromStart=searchFromStart;
    this->matchCase=matchCase;
    this->wholeWords=wholeWords;
    this->searchPhrase=phrase;
    this->replacePhrase=replaceBy;
    this->replaceAll=replaceAll;
    this->askBeforeReplace=askBeforeReplace;
    currentlySearching=false;
    currentlyReplacing=true;

    emit findNextAvailable(true);


    QTextCursor c(textCursor());
    c.clearSelection();
    if (searchFromStart) {
        c.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);
        while (!c.atStart()) {
            c.movePosition(QTextCursor::Up, QTextCursor::MoveAnchor);
        }
    }
    setTextCursor(c);

    // find the next occurence
    QTextDocument::FindFlags flags=0;
    if (matchCase) flags |= QTextDocument::FindCaseSensitively;
    if (wholeWords) flags |= QTextDocument::FindWholeWords;
    if (replaceAll) {
        long count=0;
        bool stopped=false;
        while (find(phrase, flags) && !stopped) {
            if (askBeforeReplace) {
                QMessageBox::StandardButton ret;
                ret = QMessageBox::question(this, tr("Find & Replace ..."),
                             tr("Replace this occurence?"),
                             QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
                if (ret == QMessageBox::Cancel) {
                    stopped=true;
                } else if (ret == QMessageBox::Yes) {
                    QTextCursor c(textCursor());
                    c.insertText(replacePhrase);
                    setTextCursor(c);
                    count++;
                }

            } else {
                QTextCursor c(textCursor());
                c.insertText(replacePhrase);
                setTextCursor(c);
                count++;
            }
        }
        if (count>0) QMessageBox::information(this, tr("Find & Replace ..."),
                             tr("Replaced %1 occurences of '%2' ...")
                             .arg(count)
                             .arg(searchPhrase));
        emit findNextAvailable(false);
        return (count>0);
    } else {
        if (!find(searchPhrase, flags)) {
            /*QMessageBox::information(this, tr("Find & Replace ..."),
                             tr("Did not find '%1' ...")
                             .arg(searchPhrase));*/
            emit findNextAvailable(false);
            return false;
        } else {
            if (askBeforeReplace) {
                QMessageBox::StandardButton ret;
                ret = QMessageBox::question(this, tr("Find & Replace ..."),
                             tr("Replace this occurence?"),
                             QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
                if (ret == QMessageBox::Cancel) {
                    emit findNextAvailable(false);
                    return true;
                } else if (ret == QMessageBox::Yes) {
                    QTextCursor c(textCursor());
                    c.insertText(replacePhrase);
                    setTextCursor(c);
                    emit findNextAvailable(true);
                    return true;
                } else if (ret == QMessageBox::No) {
                    emit findNextAvailable(true);
                    return true;
                }

            } else {
                QTextCursor c(textCursor());
                c.insertText(replacePhrase);
                setTextCursor(c);
                emit findNextAvailable(true);
                return true;
            }
        }
    }
    emit findNextAvailable(false);
    return false;
}
Exemplo n.º 16
0
//-------------------------------------------------------------------------------------------------
void QCommandPrompt::keyPressEvent(QKeyEvent *e)
{
    // Wenn Enter gedrückt wird, wird die Eingabe als Kommando interpretiert
    switch(e->key())
    {
    case Qt::Key_Return:
        {
            // Alles zwischen Promptposition und dem Textende ist das Kommando
            QString sAll = toPlainText();
            QString sCmd = sAll.right(sAll.count() - m_nPromptPos);

            if (sCmd.length()>0 && (m_vHistory.size()==0 || m_vHistory.back()!=sCmd) )
            {
                m_vHistory.push_back(sCmd);

                while (m_vHistory.size() > m_nMaxHist)
                    m_vHistory.removeFirst();

                m_nHistPos = m_vHistory.size() - 1;
            }

            sCmd = sCmd.trimmed();
            if (!sCmd.isEmpty())
            {
                addLine(getPrompt() + sCmd.trimmed());
                emit commandInput(sCmd);
            }

            // Textcursor ans Ende versetzen
            QTextCursor tc = textCursor();
            tc.movePosition(QTextCursor::End);
            setTextCursor(tc);
        }
        break;

    case Qt::Key_Up:
    case Qt::Key_Down:
        if (m_vHistory.size()==0)
            break;

        clearLineExceptPrompt();
        insertPlainText(m_vHistory[m_nHistPos]);

        m_nHistPos = m_nHistPos + ((e->key()==Qt::Key_Up) ? -1 : 1);
        m_nHistPos = Utils::clamp(0, m_vHistory.size()-1, m_nHistPos);
        break;

    case Qt::Key_Home:
        {
            QTextCursor tc = textCursor();
            Qt::KeyboardModifiers mod = e->modifiers();
            if (mod & Qt::ShiftModifier)
                tc.setPosition(m_nPromptPos, QTextCursor::KeepAnchor);
            else
                tc.setPosition(m_nPromptPos, QTextCursor::MoveAnchor);

            setTextCursor(tc);

        }
        break;

    case Qt::Key_Backspace:
    case Qt::Key_Left:
        {
            int nPos = textCursor().position();
            if (nPos > m_nPromptPos)
                QPlainTextEdit::keyPressEvent(e);
        }
        break;

    default:
        {
            int nPos = textCursor().position();
            if (nPos < m_nPromptPos)
            {
                QTextCursor tc = textCursor();
                tc.movePosition(QTextCursor::End);
                setTextCursor(tc);
            }

            QPlainTextEdit::keyPressEvent(e);
        }
    }
}
Exemplo n.º 17
0
bool GenericCodeEditor::find( const QRegExp &expr, QTextDocument::FindFlags options )
{
    // Although QTextDocument provides a find() method, we implement
    // our own, because the former one is not adequate.

    if(expr.isEmpty()) return true;

    bool backwards = options & QTextDocument::FindBackward;

    QTextCursor c( textCursor() );
    int pos;
    if (c.hasSelection())
    {
        bool matching = expr.exactMatch(c.selectedText());

        if( backwards == matching )
            pos = c.selectionStart();
        else
            pos = c.selectionEnd();
    }
    else
        pos = c.position();

    QTextDocument *doc = QPlainTextEdit::document();
    QTextBlock startBlock = doc->findBlock(pos);
    int startBlockOffset = pos - startBlock.position();

    QTextCursor cursor;

    if (!backwards) {
        int blockOffset = startBlockOffset;
        QTextBlock block = startBlock;
        while (block.isValid()) {
            if (findInBlock(doc, block, expr, blockOffset, options, cursor))
                break;
            blockOffset = 0;
            block = block.next();
        }
        if(cursor.isNull())
        {
            blockOffset = 0;
            block = doc->begin();
            while(true) {
                if (findInBlock(doc, block, expr, blockOffset, options, cursor)
                    || block == startBlock)
                    break;
                block = block.next();
            }
        }
    } else {
        int blockOffset = startBlockOffset;
        QTextBlock block = startBlock;
        while (block.isValid()) {
            if (findInBlock(doc, block, expr, blockOffset, options, cursor))
                break;
            block = block.previous();
            blockOffset = block.length() - 1;
        }
        if(cursor.isNull())
        {
            block = doc->end();
            while(true) {
                blockOffset = block.length() - 1;
                if (findInBlock(doc, block, expr, blockOffset, options, cursor)
                    || block == startBlock)
                    break;
                block = block.previous();
            }
        }
    }

    if(!cursor.isNull()) {
        setTextCursor(cursor);
        return true;
    }
    else
        return false;
}
void KNoteEdit::textIncreaseIndent()
{
  QTextBlockFormat f = textCursor().blockFormat();
  f.setIndent( f.indent() + 1 );
  textCursor().setBlockFormat( f );
}
Exemplo n.º 19
0
void SourceViewerWidget::updateTextCursor()
{
	m_findTextAnchor = textCursor();
}
Exemplo n.º 20
0
void TextEditor::addSymbol(const QString& letter)
{
	textCursor().insertText(letter);
}
Exemplo n.º 21
0
void LiteEditorWidget::keyPressEvent(QKeyEvent *e)
{
    if (m_completer && m_completer->popup()->isVisible()) {
        // The following keys are forwarded by the completer to the widget
        switch (e->key()) {
        case Qt::Key_Enter:
        case Qt::Key_Return:
        case Qt::Key_Escape:
        case Qt::Key_Tab:
        case Qt::Key_Backtab:
            e->ignore();
            return; // let the completer do default behavior
        default:
            break;
        }
    }

    LiteEditorWidgetBase::keyPressEvent(e);

    const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
    if (!m_completer || (ctrlOrShift && e->text().isEmpty()))
        return;

    if (e->modifiers() & Qt::ControlModifier) {
        m_completer->popup()->hide();
        return;
    }
    if (e->key() == Qt::Key_Tab || e->key() == Qt::Key_Backtab) {
        return;
    }
    //static QString eow("~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word
    static QString eow("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-="); // end of word
    bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift;
    QString completionPrefix = textUnderCursor(textCursor());
    if (completionPrefix.startsWith(".")) {
        completionPrefix.insert(0,'@');
    }

    if (hasModifier || e->text().isEmpty()||
                        ( completionPrefix.length() < m_completionPrefixMin && completionPrefix.right(1) != ".")
                        || eow.contains(e->text().right(1))) {
        m_completer->popup()->hide();
        return;
    }
    emit completionPrefixChanged(completionPrefix);

    if (completionPrefix != m_completer->completionPrefix()) {
        m_completer->setCompletionPrefix(completionPrefix);
        m_completer->popup()->setCurrentIndex(m_completer->completionModel()->index(0, 0));
    }

    if (m_completer->currentCompletion() == completionPrefix) {
        m_completer->popup()->hide();
        return;
    }

    QRect cr = cursorRect();
    cr.setWidth(m_completer->popup()->sizeHintForColumn(0)
                + m_completer->popup()->verticalScrollBar()->sizeHint().width());

    m_completer->complete(cr); // popup it up!
}
Exemplo n.º 22
0
void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    setTextInteractionFlags(Qt::TextEditorInteraction);

    // scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
    // It is a cludge...
    if (UBStylusTool::Play == UBDrawingController::drawingController()->stylusTool())
    {
        QGraphicsTextItem::mousePressEvent(event);
        event->accept();
        clearFocus();
        return;
    }

    if (Delegate())
    {
        Delegate()->mousePressEvent(event);
        if (Delegate() && parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
        {
            UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem());
            if (group)
            {
                QGraphicsItem *curItem = group->getCurrentItem();
                if (curItem && this != curItem)
                {
                    group->deselectCurrentItem();
                }
                group->setCurrentItem(this);
                this->setSelected(true);
                Delegate()->positionHandles();
            }

        }
        else
        {
            Delegate()->getToolBarItem()->show();
        }

    }

    if (!data(UBGraphicsItemData::ItemEditable).toBool())
        return;

    int elapsed = mLastMousePressTime.msecsTo(QTime::currentTime());

    if (elapsed < UBApplication::app()->doubleClickInterval())
    {
        mMultiClickState++;
        if (mMultiClickState > 3)
            mMultiClickState = 1;
    }
    else
    {
        mMultiClickState = 1;
    }

    mLastMousePressTime = QTime::currentTime();

    if (mMultiClickState == 1)
    {
        QGraphicsTextItem::mousePressEvent(event);
        setFocus();
    }
    else if (mMultiClickState == 2)
    {
        QTextCursor tc= textCursor();
        tc.select(QTextCursor::WordUnderCursor);
        setTextCursor(tc);
    }
    else if (mMultiClickState == 3)
    {
        QTextCursor tc= textCursor();
        tc.select(QTextCursor::Document);
        setTextCursor(tc);
    }
    else
    {
        mMultiClickState = 0;
    }
}
Exemplo n.º 23
0
/**
 * Append new text
 * @param txt :: The text to append
 */
void ScriptOutputDisplay::appendText(const QString &txt) {
  textCursor().insertText(txt);
  moveCursor(QTextCursor::End);
}
Exemplo n.º 24
0
bool QMultiLineEdit::atEnd() const
{
    return textCursor()->paragraph() == document()->lastParagraph() && textCursor()->atParagEnd();
}
Exemplo n.º 25
0
// This function overrides the QWidget::event() and should return true if the
// event was recognized, otherwise it should return false. If the recognized
// event was accepted (see QEvent::accepted), any further processing such as
// event propagation to the parent widget stops.
bool TCommandLine::event(QEvent* event)
{
    const Qt::KeyboardModifiers allModifiers = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier;
    if (event->type() == QEvent::KeyPress) {
        auto * ke = dynamic_cast<QKeyEvent*>(event);

        // Shortcut for keypad keys
        if ((ke->modifiers() & Qt::KeypadModifier) && mpKeyUnit->processDataStream(ke->key(), (int)ke->modifiers())) {
            ke->accept();
            return true;

        }

        switch (ke->key()) {
        case Qt::Key_Space:
            if ((ke->modifiers() & (allModifiers & ~(Qt::ShiftModifier))) == Qt::NoModifier) {
                // Ignore the <SHIFT> modifier only - keeps some users happy!
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mTabCompletionTyped.clear();
                mAutoCompletionTyped.clear();
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                mLastCompletion.clear();
                break;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than just a <SHIFT> one; may actaully be configured as
                // a non-breaking space when used with a modifier!
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Backtab:
            // <BACKTAB> is usually internally generated by SHIFT used in
            // conjunction with TAB - so ignore just the SHIFT key:
            if ((ke->modifiers() & (allModifiers & ~(Qt::ShiftModifier))) == Qt::ControlModifier) {
                // Switch to PREVIOUS profile tab when used with <CTRL> (and
                // implicit <SHIFT>):
                int currentIndex = mudlet::self()->mpTabBar->currentIndex();
                int count = mudlet::self()->mpTabBar->count();
                if (currentIndex - 1 < 0) {
                    mudlet::self()->mpTabBar->setCurrentIndex(count - 1);
                } else {
                    mudlet::self()->mpTabBar->setCurrentIndex(currentIndex - 1);
                }
                ke->accept();
                return true;

            } else if ((ke->modifiers() & (allModifiers & ~(Qt::ShiftModifier))) ==  Qt::NoModifier) {
                // Process as plain <BACKTAB> - (ignoring implicit <SHIFT>)
                handleTabCompletion(false);
                adjustHeight();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than just the ignored <SHIFT> and the possible <CTRL>:
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Tab:
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
                // Switch to NEXT profile tab
                int currentIndex = mudlet::self()->mpTabBar->currentIndex();
                int count = mudlet::self()->mpTabBar->count();
                if (currentIndex + 1 < count) {
                    mudlet::self()->mpTabBar->setCurrentIndex(currentIndex + 1);
                } else {
                    mudlet::self()->mpTabBar->setCurrentIndex(0);
                }
                ke->accept();
                return true;

            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                handleTabCompletion(true);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than just the Ctrl one
                // CHECKME: What about system foreground application switching?
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_unknown:
            qWarning() << "ERROR: key unknown!";
            break;

        case Qt::Key_Backspace:
            if ((ke->modifiers() & (allModifiers & ~(Qt::ControlModifier|Qt::ShiftModifier))) == Qt::NoModifier) {
                // Ignore state of <CTRL> and <SHIFT> keys
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }

                if (mTabCompletionTyped.size() >= 1) {
                    mTabCompletionTyped.chop(1);
                    mAutoCompletionTyped.chop(1);
                }
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mLastCompletion.clear();
                QPlainTextEdit::event(event);

                adjustHeight();

                return true;
            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than <CTRL> and/or <SHIFT>
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Delete:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }

                if (mTabCompletionTyped.size() >= 1) {
                    mTabCompletionTyped.chop(1);
                    mAutoCompletionTyped.chop(1);
                } else {
                    mTabCompletionTyped.clear();
                    mAutoCompletionTyped.clear();
                    mUserKeptOnTyping = false;
                }
                mAutoCompletionCount = -1;
                mTabCompletionCount = -1;
                mLastCompletion.clear();
                QPlainTextEdit::event(event);
                adjustHeight();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Return: // This is the main one (not the keypad)
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
                // If Ctrl-Return is pressed - scroll to the bottom of text:
                mpConsole->mLowerPane->mCursorY = mpConsole->buffer.size();
                mpConsole->mLowerPane->hide();
                mpConsole->buffer.mCursorY = mpConsole->buffer.size();
                mpConsole->mUpperPane->mCursorY = mpConsole->buffer.size();
                mpConsole->mUpperPane->mIsTailMode = true;
                mpConsole->mUpperPane->updateScreenView();
                mpConsole->mUpperPane->forceUpdate();
                ke->accept();
                return true;

            } else if ((ke->modifiers() & allModifiers) == Qt::ShiftModifier) {
                textCursor().insertBlock();
                ke->accept();
                return true;

            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                // Do the normal return key stuff only if NO modifiers are used:
                enterCommand(ke);
                mAutoCompletionCount = -1;
                mAutoCompletionTyped.clear();
                mLastCompletion.clear();
                mTabCompletionTyped.clear();
                mUserKeptOnTyping = false;
                mTabCompletionCount = -1;
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    clear();
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                adjustHeight();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Shift or just the Control modifiers
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Enter:
            // This is usually the Keypad one, so may come with
            // the keypad modifier - but if so it may never be reached because
            // of the keypad modifier interception done before this switch...
            if ((ke->modifiers() & (allModifiers & ~(Qt::KeypadModifier))) == Qt::NoModifier) {
                // Do the "normal" return key action if no or just the keypad
                // modifier is present:
                enterCommand(ke);
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mLastCompletion.clear();
                mTabCompletionTyped.clear();
                mAutoCompletionTyped.clear();
                mUserKeptOnTyping = false;
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    clear();
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                adjustHeight();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Keypad modifier
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Down:
#if defined(Q_OS_MACOS)
            if ((ke->modifiers() & allModifiers) == (Qt::ControlModifier|Qt::KeypadModifier)) {
#else
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
#endif
                // If EXACTLY <Ctrl>-Down is pressed (special case for macOs -
                // also sets KeyPad modifier)
                moveCursor(QTextCursor::Down, QTextCursor::MoveAnchor);
                ke->accept();
                return true;

#if defined(Q_OS_MACOS)
            } else if ((ke->modifiers() & allModifiers) == Qt::KeypadModifier) {
#else
            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
#endif
                // If EXACTLY Down is pressed without modifiers (special case
                // for macOs - also sets KeyPad modifier)
                historyDown(ke);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Control modifier (or keypad modifier on
                // macOs)
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Up:
#if defined(Q_OS_MACOS)
            if ((ke->modifiers() & allModifiers) == (Qt::ControlModifier|Qt::KeypadModifier)) {
#else
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
#endif
                // If EXACTLY <Ctrl>-Up is pressed (special case for macOs -
                // also sets KeyPad modifier)
                moveCursor(QTextCursor::Up, QTextCursor::MoveAnchor);
                ke->accept();
                return true;

#if defined(Q_OS_MACOS)
            } else if ((ke->modifiers() & allModifiers) == Qt::KeypadModifier) {
#else
            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
#endif
                // If EXACTLY Up is pressed without modifiers (special case for
                // macOs - also sets KeyPad modifier)
                historyUp(ke);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Control modifier (or keypad modifier on
                // macOs)
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Escape:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                // Escape from tab completion mode if used with NO modifiers
                selectAll();
                mAutoCompletion = false;
                mTabCompletion = false;
                mTabCompletionTyped.clear();
                mAutoCompletionTyped.clear();
                mUserKeptOnTyping = false;
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                setPalette(mRegularPalette);
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_PageUp:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                mpConsole->scrollUp(mpHost->mScreenHeight);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_PageDown:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                mpConsole->scrollDown(mpHost->mScreenHeight);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_C:
            if (((ke->modifiers() & allModifiers) == Qt::ControlModifier)
                && (mpConsole->mUpperPane->mSelectedRegion != QRegion(0, 0, 0, 0))) {

                // Only process as a Control-C if it is EXACTLY those two keys
                // and no other AND there is a selection active in the TConsole
                mpConsole->mUpperPane->slot_copySelectionToClipboard();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                if (processPotentialKeyBinding(ke)) {
                    return true;

                } else {
                    processNormalKey(event);
                    return false;

                }
            }

        default:
            // Process as a possible key binding if there are ANY modifiers,
            if (processPotentialKeyBinding(ke)) {
                return true;

            } else {
                processNormalKey(event);
                return false;

            }
        }
    }

    return QPlainTextEdit::event(event);
}

void TCommandLine::focusInEvent(QFocusEvent* event)
{
    textCursor().movePosition(QTextCursor::Start);
    textCursor().movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, mSelectedText.length());

    mpConsole->mUpperPane->forceUpdate();
    mpConsole->mLowerPane->forceUpdate();
    QPlainTextEdit::focusInEvent(event);
}
Exemplo n.º 26
0
bool QMultiLineEdit::atBeginning() const
{
    return textCursor()->paragraph() == document()->firstParagraph() && textCursor()->atParagStart();
}
Exemplo n.º 27
0
void GroupedLineEdit::setCursorPosition(int position)
{
	QTextCursor c = textCursor();
	c.setPosition(position, QTextCursor::MoveAnchor);
	setTextCursor(c);
}
Exemplo n.º 28
0
void QMultiLineEdit::insertAndMark( const QString& str, bool mark )
{
    insert( str );
    if ( mark )
	document()->setSelectionEnd( QTextDocument::Standard, *textCursor() );
}
Exemplo n.º 29
0
int GroupedLineEdit::cursorPosition() const
{
	return textCursor().positionInBlock();
}
Exemplo n.º 30
0
QPoint QMultiLineEdit::cursorPoint() const
{
    return QPoint( textCursor()->x(), textCursor()->y() + textCursor()->paragraph()->rect().y() );
}