2020#include " qgscomposition.h"
2121#include < QFileDialog>
2222#include < QSettings>
23+ #include < Qsci/qsciscintilla.h>
24+ #include < Qsci/qscilexerhtml.h>
2325
2426QgsComposerHtmlWidget::QgsComposerHtmlWidget ( QgsComposerHtml* html, QgsComposerFrame* frame ): QgsComposerItemBaseWidget( 0 , html ), mHtml( html ), mFrame( frame )
2527{
2628 setupUi ( this );
2729
30+ // setup html editor
31+ mHtmlEditor = new QsciScintilla ( this );
32+ mHtmlEditor ->setLexer ( new QsciLexerHTML );
33+ mHtmlEditor ->setFolding ( QsciScintilla::BoxedFoldStyle );
34+ // hide the line numbers
35+ mHtmlEditor ->setMarginWidth ( 1 , 0 );
36+
37+ connect ( mHtmlEditor , SIGNAL ( textChanged () ), this , SLOT ( htmlEditorChanged () ) );
38+ htmlEditorLayout->addWidget ( mHtmlEditor );
39+
2840 blockSignals ( true );
2941 mResizeModeComboBox ->addItem ( tr ( " Use existing frames" ), QgsComposerMultiFrame::UseExistingFrames );
3042 mResizeModeComboBox ->addItem ( tr ( " Extend to next page" ), QgsComposerMultiFrame::ExtendToNextPage );
@@ -62,7 +74,7 @@ void QgsComposerHtmlWidget::blockSignals( bool block )
6274 mResizeModeComboBox ->blockSignals ( block );
6375 mUseSmartBreaksCheckBox ->blockSignals ( block );
6476 mMaxDistanceSpinBox ->blockSignals ( block );
65- mHtmlTextEdit ->blockSignals ( block );
77+ mHtmlEditor ->blockSignals ( block );
6678 mRadioManualSource ->blockSignals ( block );
6779 mRadioUrlSource ->blockSignals ( block );
6880}
@@ -149,14 +161,14 @@ void QgsComposerHtmlWidget::on_mMaxDistanceSpinBox_valueChanged( double val )
149161 mHtml ->setMaxBreakDistance ( val );
150162}
151163
152- void QgsComposerHtmlWidget::on_mHtmlTextEdit_textChanged ()
164+ void QgsComposerHtmlWidget::htmlEditorChanged ()
153165{
154166 if ( !mHtml )
155167 {
156168 return ;
157169 }
158170
159- mHtml ->setHtml ( mHtmlTextEdit -> toPlainText () );
171+ mHtml ->setHtml ( mHtmlEditor -> text () );
160172}
161173
162174void QgsComposerHtmlWidget::on_mRadioManualSource_clicked ( bool checked )
@@ -167,7 +179,7 @@ void QgsComposerHtmlWidget::on_mRadioManualSource_clicked( bool checked )
167179 }
168180
169181 mHtml ->setContentMode ( checked ? QgsComposerHtml::ManualHtml : QgsComposerHtml::Url );
170- mHtmlTextEdit ->setEnabled ( checked );
182+ mHtmlEditor ->setEnabled ( checked );
171183 mUrlLineEdit ->setEnabled ( !checked );
172184 mFileToolButton ->setEnabled ( !checked );
173185
@@ -182,7 +194,7 @@ void QgsComposerHtmlWidget::on_mRadioUrlSource_clicked( bool checked )
182194 }
183195
184196 mHtml ->setContentMode ( checked ? QgsComposerHtml::Url : QgsComposerHtml::ManualHtml );
185- mHtmlTextEdit ->setEnabled ( !checked );
197+ mHtmlEditor ->setEnabled ( !checked );
186198 mUrlLineEdit ->setEnabled ( checked );
187199 mFileToolButton ->setEnabled ( checked );
188200
@@ -236,12 +248,12 @@ void QgsComposerHtmlWidget::setGuiElementValues()
236248 mMaxDistanceSpinBox ->setValue ( mHtml ->maxBreakDistance () );
237249
238250 mAddFramePushButton ->setEnabled ( mHtml ->resizeMode () == QgsComposerMultiFrame::UseExistingFrames );
239- mHtmlTextEdit -> setPlainText ( mHtml ->html () );
251+ mHtmlEditor -> setText ( mHtml ->html () );
240252
241253 mRadioUrlSource ->setChecked ( mHtml ->contentMode () == QgsComposerHtml::Url );
242254 mUrlLineEdit ->setEnabled ( mHtml ->contentMode () == QgsComposerHtml::Url );
243255 mFileToolButton ->setEnabled ( mHtml ->contentMode () == QgsComposerHtml::Url );
244256 mRadioManualSource ->setChecked ( mHtml ->contentMode () == QgsComposerHtml::ManualHtml );
245- mHtmlTextEdit ->setEnabled ( mHtml ->contentMode () == QgsComposerHtml::ManualHtml );
257+ mHtmlEditor ->setEnabled ( mHtml ->contentMode () == QgsComposerHtml::ManualHtml );
246258 blockSignals ( false );
247259}
0 commit comments