texteditor.cpp
changeset 842 bec082472471
parent 829 832e96c9abb6
     1.1 --- a/texteditor.cpp	Mon Mar 22 15:37:23 2010 +0000
     1.2 +++ b/texteditor.cpp	Tue Mar 30 17:30:39 2010 +0000
     1.3 @@ -232,18 +232,40 @@
     1.4  	setFontHint (note.getFontHint() );
     1.5  }
     1.6  
     1.7 -bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags, QTextCursor &cursor)
     1.8 +bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags)
     1.9  {
    1.10  	if (e->find (t,flags))
    1.11 +		return true;
    1.12 +	else	
    1.13 +		return false;
    1.14 +}
    1.15 +
    1.16 +bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags, int i)
    1.17 +{
    1.18 +	// Position at beginning
    1.19 +	QTextCursor c=e->textCursor();
    1.20 +	c.setPosition (0,QTextCursor::MoveAnchor);
    1.21 +	e->setTextCursor (c);
    1.22 +
    1.23 +	// Search for t
    1.24 +	int j=0;
    1.25 +	while (j<=i)
    1.26  	{
    1.27 -		cursor=e->textCursor();
    1.28 -		return true;
    1.29 -	}	
    1.30 -	else	
    1.31 -	{
    1.32 -		cursor=QTextCursor();
    1.33 -		return false;
    1.34 +		if (!e->find (t,flags)) return false;
    1.35 +		j++;
    1.36  	}
    1.37 +	return true;
    1.38 +
    1.39 +}
    1.40 +
    1.41 +void TextEditor::setTextCursor (const QTextCursor &cursor)
    1.42 +{
    1.43 +	e->setTextCursor (cursor);
    1.44 +}
    1.45 +
    1.46 +QTextCursor TextEditor::getTextCursor()
    1.47 +{
    1.48 +	return e->textCursor();
    1.49  }
    1.50  
    1.51  void TextEditor::setupFileActions()
    1.52 @@ -808,6 +830,11 @@
    1.53  
    1.54  void TextEditor::textAlign( QAction *a )
    1.55  {
    1.56 +	qDebug()<<"TE::textAlign";
    1.57 +	QTextCursor c=e->textCursor();
    1.58 +	c.setPosition (3,QTextCursor::MoveAnchor);
    1.59 +	e->setTextCursor (c);
    1.60 +
    1.61      if ( a == actionAlignLeft )
    1.62  		e->setAlignment( Qt::AlignLeft );
    1.63      else if ( a == actionAlignCenter )