texteditor.cpp
changeset 804 14f2b1b15242
parent 746 ee6b0f3a4c2f
child 805 fc7a93ff97c3
     1.1 --- a/texteditor.cpp	Fri Oct 02 14:31:03 2009 +0000
     1.2 +++ b/texteditor.cpp	Fri Nov 13 08:32:03 2009 +0000
     1.3 @@ -15,6 +15,8 @@
     1.4  extern QString iconPath;
     1.5  extern QString vymName;
     1.6  
     1.7 +extern bool debug;
     1.8 +
     1.9  using namespace std;
    1.10  
    1.11  
    1.12 @@ -110,6 +112,30 @@
    1.13  
    1.14  }
    1.15  
    1.16 +void TextEditor::reset()
    1.17 +{
    1.18 +	e->clear();
    1.19 +	actionFormatUseFixedFont->setOn (false);
    1.20 +    actionTextBold->setOn (false);
    1.21 +	e->setBold (false);
    1.22 +
    1.23 +	actionTextUnderline->setOn (false);
    1.24 +	e->setUnderline (false);
    1.25 +
    1.26 +	actionTextItalic->setOn (false);
    1.27 +	e->setItalic (false);
    1.28 +
    1.29 +    QPixmap pix( 16, 16 );
    1.30 +    pix.fill( Qt::black );
    1.31 +    actionTextColor->setIconSet( pix );
    1.32 +	e->setColor (Qt::black);
    1.33 +
    1.34 +	actionAlignSubScript->setOn (false);
    1.35 +	actionAlignSuperScript->setOn (false);
    1.36 +	actionAlignLeft->setOn (true);
    1.37 +	e->setAlignment( Qt::AlignLeft );
    1.38 +}
    1.39 +
    1.40  bool TextEditor::isEmpty()
    1.41  {
    1.42  	if (e->toPlainText().length()>0)
    1.43 @@ -547,7 +573,14 @@
    1.44  {
    1.45  	blockChangedSignal=true;
    1.46  	e->setReadOnly(false);
    1.47 -	e->setText(t);
    1.48 +	reset();
    1.49 +	if (Qt::mightBeRichText (t))
    1.50 +		e->setHtml(t);
    1.51 +	else
    1.52 +	{
    1.53 +		actionFormatUseFixedFont->setChecked (true);
    1.54 +		e->setPlainText(t);
    1.55 +	}	
    1.56  	enableActions();
    1.57  	blockChangedSignal=false;
    1.58  }