Skip to content

Commit

Permalink
Merge composer ruler branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Mar 24, 2013
2 parents 920036e + 56b55a0 commit eb95e50
Show file tree
Hide file tree
Showing 36 changed files with 619 additions and 26 deletions.
61 changes: 40 additions & 21 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgscomposerruler.h"
#include "qgscomposerview.h"
#include "qgscomposition.h"
#include "qgscompositionwidget.h"
Expand Down Expand Up @@ -269,8 +270,22 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
setMouseTracking( true );
mViewFrame->setMouseTracking( true );

//create composer view
mView = new QgsComposerView( mViewFrame );
//create composer view and layout with rulers
mView = 0;
mViewLayout = new QGridLayout();
mViewLayout->setSpacing( 0 );
mViewLayout->setMargin( 0 );
mHorizontalRuler = new QgsComposerRuler( QgsComposerRuler::Horizontal );
mVerticalRuler = new QgsComposerRuler( QgsComposerRuler::Vertical );
QWidget* fake = new QWidget();
fake->setAttribute( Qt::WA_NoMousePropagation );
fake->setBackgroundRole( QPalette::Window );
fake->setFixedSize( 20, 20 );
mViewLayout->addWidget( fake, 0, 0 );
mViewLayout->addWidget( mHorizontalRuler, 0, 1 );
mViewLayout->addWidget( mVerticalRuler, 1, 0 );
createComposerView();
mViewFrame->setLayout( mViewLayout );

//init undo/redo buttons
mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
Expand Down Expand Up @@ -340,10 +355,6 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )

mGeneralDock->raise();

QGridLayout *l = new QGridLayout( mViewFrame );
l->setMargin( 0 );
l->addWidget( mView, 0, 0 );

// Create size grip (needed by Mac OS X for QMainWindow if QStatusBar is not visible)
mSizeGrip = new QSizeGrip( this );
mSizeGrip->resize( mSizeGrip->sizeHint() );
Expand Down Expand Up @@ -455,6 +466,10 @@ void QgsComposer::open( void )
mFirstTime = false;
show();
zoomFull(); // zoomFull() does not work properly until we have called show()
if ( mView )
{
mView->updateRulers();
}
}

else
Expand Down Expand Up @@ -578,20 +593,23 @@ void QgsComposer::zoomFull( void )
void QgsComposer::on_mActionZoomAll_triggered()
{
zoomFull();
mView->updateRulers();
mView->update();
emit zoomLevelChanged();
}

void QgsComposer::on_mActionZoomIn_triggered()
{
mView->scale( 2, 2 );
mView->updateRulers();
mView->update();
emit zoomLevelChanged();
}

void QgsComposer::on_mActionZoomOut_triggered()
{
mView->scale( .5, .5 );
mView->updateRulers();
mView->update();
emit zoomLevelChanged();
}
Expand Down Expand Up @@ -1781,21 +1799,11 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
}
}

//delete composer view and composition
delete mView;
mView = 0;
//delete every child of mViewFrame
QObjectList viewFrameChildren = mViewFrame->children();
QObjectList::iterator it = viewFrameChildren.begin();
for ( ; it != viewFrameChildren.end(); ++it )
{
delete( *it );
}
//delete composition widget
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralDock->widget() );
delete oldCompositionWidget;

mView = new QgsComposerView( mViewFrame );
createComposerView();

//read composition settings
mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
Expand All @@ -1808,10 +1816,6 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&

connectSlots();

QGridLayout *l = new QGridLayout( mViewFrame );
l->setMargin( 0 );
l->addWidget( mView, 0, 0 );

//create compositionwidget
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mGeneralDock, mComposition );
QObject::connect( mComposition, SIGNAL( paperSizeChanged() ), compositionWidget, SLOT( displayCompositionWidthHeight() ) );
Expand Down Expand Up @@ -2179,3 +2183,18 @@ QMenu* QgsComposer::mirrorOtherMenu( QMenu* otherMenu )
}
return newMenu;
}

void QgsComposer::createComposerView()
{
if ( !mViewLayout )
{
return;
}

delete mView;
mView = new QgsComposerView();
mView->setContentsMargins( 0, 0, 0, 0 );
mView->setHorizontalRuler( mHorizontalRuler );
mView->setVerticalRuler( mVerticalRuler );
mViewLayout->addWidget( mView, 1, 1 );
}
9 changes: 9 additions & 0 deletions src/app/composer/qgscomposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@

class QgisApp;
class QgsComposerArrow;
class QgsComposerFrame;
class QgsComposerHtml;
class QgsComposerLabel;
class QgsComposerLegend;
class QgsComposerPicture;
class QgsComposerPictureWidget;
class QgsComposerRuler;
class QgsComposerScaleBar;
class QgsComposerShape;
class QgsComposerAttributeTable;
Expand Down Expand Up @@ -331,11 +334,17 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! To make loading from project faster, the previews are generated when the composer becomes visible.
void initialiseComposerPicturePreviews();

//! Create composer view and rulers
void createComposerView();

/**Composer title*/
QString mTitle;

//! Pointer to composer view
QgsComposerView *mView;
QGridLayout* mViewLayout;
QgsComposerRuler* mHorizontalRuler;
QgsComposerRuler* mVerticalRuler;

//! Current composition
QgsComposition *mComposition;
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposerhtmlwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "qgscomposeritemwidget.h"
#include "qgscomposermultiframecommand.h"
#include "qgscomposerhtml.h"
#include "qgscomposition.h"
#include <QFileDialog>
#include <QSettings>

Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposerlabelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "qgscomposerlabelwidget.h"
#include "qgscomposerlabel.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
#include "qgsexpressionbuilderdialog.h"

#include <QColorDialog>
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposerlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "qgscomposerlegendlayersdialog.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include <QFontDialog>
#include <QColorDialog>

Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgscomposer.h"
#include "qgscomposition.h"
#include "qgslogger.h"

#include <QDesktopServices>
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "qgscomposermapwidget.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
#include "qgsmaprenderer.h"
#include "qgsstylev2.h"
#include "qgssymbolv2.h"
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposerpicturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "qgscomposermap.h"
#include "qgscomposerpicture.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
#include <QDoubleValidator>
#include <QFileDialog>
#include <QFileInfo>
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposerscalebarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"
#include "qgscomposerscalebar.h"
#include "qgscomposition.h"
#include <QColorDialog>
#include <QFontDialog>
#include <QWidget>
Expand Down
7 changes: 7 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

#include <qgsnetworkaccessmanager.h>
#include <qgsapplication.h>
#include <qgscomposition.h>

#include <QNetworkReply>
#include <QNetworkProxy>
Expand Down Expand Up @@ -109,6 +110,7 @@
#include "qgsclipboard.h"
#include "qgscomposer.h"
#include "qgscomposermanager.h"
#include "qgscomposerview.h"
#include "qgsconfigureshortcutsdialog.h"
#include "qgscoordinatetransform.h"
#include "qgscredentialdialog.h"
Expand Down Expand Up @@ -4787,6 +4789,11 @@ bool QgisApp::loadComposersFromProject( const QDomDocument& doc )
composer->show();
#endif
composer->zoomFull();
QgsComposerView* composerView = composer->view();
if ( composerView )
{
composerView->updateRulers();
}
if ( composerNodes.at( i ).toElement().attribute( "visible", "1" ).toInt() < 1 )
{
composer->close();
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgsaddremoveitemcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "qgsaddremoveitemcommand.h"
#include "qgscomposeritem.h"
#include "qgscomposition.h"

QgsAddRemoveItemCommand::QgsAddRemoveItemCommand( State s, QgsComposerItem* item, QgsComposition* c, const QString& text, QUndoCommand* parent ):
QUndoCommand( text, parent ), mItem( item ), mComposition( c ), mState( s ), mFirstRun( true )
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qgsatlascomposition.h"
#include "qgsvectorlayer.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgsvectordataprovider.h"
#include "qgsexpression.h"
#include "qgsgeometry.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerarrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscomposerarrow.h"
#include "qgscomposition.h"
#include <QPainter>
#include <QSvgRenderer>

Expand Down
2 changes: 2 additions & 0 deletions src/core/composer/qgscomposerarrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#define QGSCOMPOSERARROW_H

#include "qgscomposeritem.h"
#include <QBrush>
#include <QPen>

/**An item that draws an arrow between to points*/
class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "qgscomposerframe.h"
#include "qgscomposermultiframe.h"
#include "qgscomposition.h"

QgsComposerFrame::QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf, qreal x, qreal y, qreal width, qreal height )
: QgsComposerItem( x, y, width, height, c )
Expand Down
5 changes: 2 additions & 3 deletions src/core/composer/qgscomposeritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
#ifndef QGSCOMPOSERITEM_H
#define QGSCOMPOSERITEM_H

#include "qgscomposition.h"
#include "qgscomposeritemcommand.h"
#include <QGraphicsRectItem>
#include <QObject>

class QgsComposition;
class QWidget;
class QDomDocument;
class QDomElement;
class QGraphicsLineItem;

class QqsComposition;

/** \ingroup MapComposer
* A item that forms part of a map composition.
*/
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscomposerlabel.h"
#include "qgscomposition.h"
#include "qgsexpression.h"
#include <QCoreApplication>
#include <QDate>
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define QGSCOMPOSERLABEL_H

#include "qgscomposeritem.h"
#include <QFont>

class QgsVectorLayer;
class QgsFeature;
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qgscomposerlegend.h"
#include "qgscomposerlegenditem.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgslogger.h"
#include "qgsmaplayer.h"
#include "qgsmaplayerregistry.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgscoordinatetransform.h"
#include "qgslogger.h"
#include "qgsmaprenderer.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposermap.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//#include "ui_qgscomposermapbase.h"
#include "qgscomposeritem.h"
#include "qgsrectangle.h"
#include <QFont>
#include <QGraphicsRectItem>

class QgsComposition;
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposermultiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "qgscomposermultiframe.h"
#include "qgscomposerframe.h"
#include "qgscomposition.h"

QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ): mComposition( c ), mResizeMode( UseExistingFrames ), mCreateUndoCommands( createUndoCommands )
{
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerpicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "qgscomposerpicture.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgsproject.h"
#include <QDomDocument>
#include <QDomElement>
Expand Down
2 changes: 2 additions & 0 deletions src/core/composer/qgscomposerpicture.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <QImage>
#include <QSvgRenderer>

class QgsComposerMap;

/** \ingroup MapComposer
* A composer class that displays svg files or raster format (jpg, png, ...)
* */
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "qgscomposerscalebar.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgsdistancearea.h"
#include "qgsscalebarstyle.h"
#include "qgsdoubleboxscalebarstyle.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerscalebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define QGSCOMPOSERSCALEBAR_H

#include "qgscomposeritem.h"
#include <QFont>
#include <QPen>
#include <QColor>

Expand Down
2 changes: 2 additions & 0 deletions src/core/composer/qgscomposershape.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#define QGSCOMPOSERSHAPE_H

#include "qgscomposeritem.h"
#include <QBrush>
#include <QPen>

/**A composer items that draws common shapes (ellipse, triangle, rectangle)*/
class CORE_EXPORT QgsComposerShape: public QgsComposerItem
Expand Down
Loading

0 comments on commit eb95e50

Please sign in to comment.