-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,526 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#include "qgscomposerhtmlwidget.h" | ||
#include "qgscomposerframe.h" | ||
#include "qgscomposeritemwidget.h" | ||
#include "qgscomposermultiframecommand.h" | ||
#include "qgscomposerhtml.h" | ||
#include <QFileDialog> | ||
#include <QSettings> | ||
|
||
QgsComposerHtmlWidget::QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposerFrame* frame ): mHtml( html ), mFrame( frame ) | ||
{ | ||
setupUi( this ); | ||
|
||
blockSignals( true ); | ||
mResizeModeComboBox->addItem( tr( "Use existing frames" ), QgsComposerMultiFrame::UseExistingFrames ); | ||
mResizeModeComboBox->addItem( tr( "Extend to next page" ), QgsComposerMultiFrame::ExtendToNextPage ); | ||
blockSignals( false ); | ||
setGuiElementValues(); | ||
|
||
if ( mHtml ) | ||
{ | ||
QObject::connect( mHtml, SIGNAL( changed() ), this, SLOT( setGuiElementValues() ) ); | ||
} | ||
|
||
//embed widget for general options | ||
if ( mFrame ) | ||
{ | ||
//add widget for general composer item properties | ||
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, mFrame ); | ||
mToolBox->addItem( itemPropertiesWidget, tr( "General options" ) ); | ||
} | ||
} | ||
|
||
QgsComposerHtmlWidget::QgsComposerHtmlWidget() | ||
{ | ||
} | ||
|
||
QgsComposerHtmlWidget::~QgsComposerHtmlWidget() | ||
{ | ||
} | ||
|
||
void QgsComposerHtmlWidget::blockSignals( bool block ) | ||
{ | ||
mUrlLineEdit->blockSignals( block ); | ||
mFileToolButton->blockSignals( block ); | ||
mResizeModeComboBox->blockSignals( block ); | ||
} | ||
|
||
void QgsComposerHtmlWidget::on_mUrlLineEdit_editingFinished() | ||
{ | ||
if ( mHtml ) | ||
{ | ||
QUrl newUrl( mUrlLineEdit->text() ); | ||
if ( newUrl == mHtml->url() ) | ||
{ | ||
return; | ||
} | ||
|
||
QgsComposition* composition = mHtml->composition(); | ||
if ( composition ) | ||
{ | ||
composition->beginMultiFrameCommand( mHtml, tr( "Change html url" ) ); | ||
mHtml->setUrl( newUrl ); | ||
mHtml->update(); | ||
composition->endMultiFrameCommand(); | ||
} | ||
} | ||
} | ||
|
||
void QgsComposerHtmlWidget::on_mFileToolButton_clicked() | ||
{ | ||
QSettings s; | ||
QString lastDir = s.value( "/UI/lastHtmlDir", "" ).toString(); | ||
QString file = QFileDialog::getOpenFileName( this, tr( "Select HTML document" ), lastDir, "HTML (*.html)" ); | ||
if ( !file.isEmpty() ) | ||
{ | ||
QUrl url = QUrl::fromLocalFile( file ); | ||
mUrlLineEdit->setText( url.toString() ); | ||
on_mUrlLineEdit_editingFinished(); | ||
mHtml->update(); | ||
s.setValue( "/UI/lastHtmlDir", QFileInfo( file ).absolutePath() ); | ||
} | ||
} | ||
|
||
void QgsComposerHtmlWidget::on_mResizeModeComboBox_currentIndexChanged( int index ) | ||
{ | ||
if ( !mHtml ) | ||
{ | ||
return; | ||
} | ||
|
||
QgsComposition* composition = mHtml->composition(); | ||
if ( composition ) | ||
{ | ||
composition->beginMultiFrameCommand( mHtml, tr( "Change resize mode" ) ); | ||
mHtml->setResizeMode(( QgsComposerMultiFrame::ResizeMode )mResizeModeComboBox->itemData( index ).toInt() ); | ||
composition->endMultiFrameCommand(); | ||
} | ||
} | ||
|
||
void QgsComposerHtmlWidget::setGuiElementValues() | ||
{ | ||
if ( !mHtml ) | ||
{ | ||
return; | ||
} | ||
|
||
blockSignals( true ); | ||
mUrlLineEdit->setText( mHtml->url().toString() ); | ||
mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mHtml->resizeMode() ) ); | ||
blockSignals( false ); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef QGSCOMPOSERHTMLWIDGET_H | ||
#define QGSCOMPOSERHTMLWIDGET_H | ||
|
||
#include "ui_qgscomposerhtmlwidgetbase.h" | ||
|
||
class QgsComposerHtml; | ||
class QgsComposerFrame; | ||
|
||
class QgsComposerHtmlWidget: public QWidget, private Ui::QgsComposerHtmlWidgetBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposerFrame* frame ); | ||
~QgsComposerHtmlWidget(); | ||
|
||
private slots: | ||
void on_mUrlLineEdit_editingFinished(); | ||
void on_mFileToolButton_clicked(); | ||
void on_mResizeModeComboBox_currentIndexChanged( int index ); | ||
|
||
/**Sets the GUI elements to the values of mHtmlItem*/ | ||
void setGuiElementValues(); | ||
|
||
private: | ||
QgsComposerHtmlWidget(); | ||
void blockSignals( bool block ); | ||
|
||
QgsComposerHtml* mHtml; | ||
QgsComposerFrame* mFrame; | ||
}; | ||
|
||
#endif // QGSCOMPOSERHTMLWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.