qgis_tabs.patch

lynxID -, 2009-05-02 10:35 AM

Download (50 KB)

View differences:

/usr/local/src/qgis/python/gui/qgstabwidget.sip (revision 0)
1
/** \class QgsMapCanvasLayer
2
 * Class provides a stack of tabbed widgets
3
*/
4
class QgsTabWidget: QTabWidget
5
{
6
%TypeHeaderCode
7
#include <qgstabwidget.h>
8
%End
9

  
10
public:
11
  QgsTabWidget(QWidget *parent); 
12
  void addTab(QWidget *widget, const QIcon &icon, const QString &label);
13
  void addTab(QWidget *widget, const QString &label);
14
  void insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label);
15
  void insertTab(int index, QWidget *widget, const QString &label);
16
  void removeTab(int index);
17
};
18

  
/usr/local/src/qgis/python/gui/qgisinterface.sip (working copy)
72 72
    /** Return a pointer to the map canvas */
73 73
    virtual QgsMapCanvas * mapCanvas()=0;
74 74

  
75
    /** Return a pointer to the main tab widget */
76
    virtual QgsTabWidget * tabWidget()=0;
77

  
75 78
    /** Return a pointer to the main window (instance of QgisApp in case of QGIS) */
76 79
    virtual QWidget * mainWindow()=0;
77 80

  
......
92 95
	/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
93 96
	virtual void removeDockWidget ( QDockWidget * dockwidget )=0;
94 97

  
98
    /** Add a tab widget to the main window */
99
    virtual void addTabWidget( QWidget *page, const QString &label )=0;
100

  
101
    /** Add a tab widget to the main window with icon */
102
    virtual void addTabWidget( QWidget *page, const QIcon &icon, const QString &label )=0;
103

  
104
    /** Insert a tab widget to the main window with label */
105
    virtual void insertTabWidget( int index, QWidget *page, const QString &label )=0;
106

  
107
    /** Insert a tab widget to the main window with icon and label */
108
    virtual void insertTabWidget( int index, QWidget *page, const QIcon &icon, const QString &label )=0;
109

  
110
    /** Remove specified tab widget from main window (doesn't delete it) */
111
    virtual void removeTabWidget( int index )=0;
112

  
95 113
    /** refresh legend of a layer */
96 114
    virtual void refreshLegend( QgsMapLayer * layer )=0;
97 115

  
/usr/local/src/qgis/python/gui/gui.sip (working copy)
25 25
%Include qgsprojectionselector.sip
26 26
%Include qgsquickprint.sip
27 27
%Include qgsrubberband.sip
28
%Include qgstabwidget.sip
28 29
%Include qgsvertexmarker.sip
29 30

  
/usr/local/src/qgis/src/app/qgisappinterface.h (working copy)
87 87
    /** Return a pointer to the map canvas used by qgisapp */
88 88
    QgsMapCanvas * mapCanvas();
89 89

  
90
    /** Return a pointer to the main tab widget that containing map canvas */
91
    QgsTabWidget * tabWidget();
92

  
90 93
    /** Gives access to main QgisApp object
91 94

  
92 95
        Plugins don't need to know about QgisApp, as we pass it as QWidget,
......
107 110
    /** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
108 111
    void removeDockWidget( QDockWidget * dockwidget );
109 112

  
113
    /** Add a tab widget to the main window */
114
    void addTabWidget( QWidget *page, const QString &label );
115

  
116
    /** Add a tab widget to the main window with icon */
117
    void addTabWidget( QWidget *page, const QIcon &icon, const QString &label );
118

  
119
    /** Insert a tab widget to the main window with label */
120
    void insertTabWidget( int index, QWidget *page, const QString &label );
121

  
122
    /** Insert a tab widget to the main window with icon and label */
123
    void insertTabWidget( int index, QWidget *page, const QIcon &icon, const QString &label );
124

  
125
    /** Remove specified tab widget from main window (doesn't delete it). */
126
    void removeTabWidget( int index );
127

  
110 128
    virtual void refreshLegend( QgsMapLayer *l );
111 129

  
112 130
    /** Add window to Window menu. The action title is the window title
/usr/local/src/qgis/src/app/qgisapp.h (working copy)
44 44
class QgsHelpViewer;
45 45
class QgsLegend;
46 46
class QgsMapCanvas;
47
class QgsMapOverviewCanvas;
47 48
class QgsMapLayer;
48 49
class QgsMapTip;
49 50
class QgsMapTool;
......
54 55
class QgsRasterLayer;
55 56
class QgsRectangle;
56 57
class QgsVectorLayer;
58
class QgsTabWidget;
57 59

  
58 60
#include <QMainWindow>
59 61
#include <QToolBar>
......
137 139
    //!Overloaded version of the private function with same name that takes the imagename as a parameter
138 140
    void saveMapAsImage( QString, QPixmap * );
139 141
    /** Get the mapcanvas object from the app */
140
    QgsMapCanvas * mapCanvas() { return mMapCanvas; };
142
    QgsMapCanvas * mapCanvas() { return mMapCanvas; }
141 143

  
144
    /** Get the tabwidget object from the app */
145
    QgsTabWidget *tabWidget() { return mTabWidget; }
146

  
142 147
    QgsComposer* printComposer() {return mComposer;}
143 148

  
144 149
    //! Set theme (icons)
......
180 185
     * After adding the dock widget to the ui (by delegating to the QMainWindow
181 186
     * parent class, it will also add it to the View menu list of docks.*/
182 187
    void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget );
188

  
189
    /** Add a tab to the tab widget with label */
190
    void addTabWidget( QWidget *page, const QString &label );
191

  
192
    /** Add a tab to the tab widget with icon and label */
193
    void addTabWidget( QWidget *page, const QIcon &icon, const QString &label );
194

  
195
    /** Insert a tab to the tab widget with label */
196
    void insertTabWidget( int index, QWidget *page, const QString &label );
197

  
198
    /** Insert a tab to the tab widget with icon and label */
199
    void insertTabWidget( int index, QWidget *page, const QIcon &icon, const QString &label );
200

  
201
    /** Remove specified tab from tab widget (doesn't delete it) */
202
    void removeTabWidget( int index );
203

  
183 204
    /** Add a toolbar to the main window. Overloaded from QMainWindow.
184 205
     * After adding the toolbar to the ui (by delegating to the QMainWindow
185 206
     * parent class, it will also add it to the View menu list of toolbars.*/
......
331 352
    void zoomToNext();
332 353
    //! Zoom to selected features
333 354
    void zoomToSelected();
355
    /** do needed procedures when user switch the tab */
356
    void twCurrentTabChanged(int index);
357
    /** do needed procedures when user move the tab */
358
    void twCurrentTabMoved(int from, int to);
359
    /** close a tab at index index */
360
    void twCloseTab(int index);
361
    /** overloaded slot of methods above that closes the current tab */
362
    void twCloseTab();
334 363

  
335 364
    //! cuts selected features on the active layer to the clipboard
336 365
    /**
......
352 381
    void editPaste( QgsMapLayer * destinationLayer = 0 );
353 382

  
354 383
    void loadOGRSublayers( QString layertype, QString uri, QStringList list );
384
    void twCreateNewTab();
355 385

  
356 386
  protected:
357 387

  
......
650 680
    void readSettings();
651 681
    void writeSettings();
652 682
    void createActions();
683
    void createActionsExt();
653 684
    void createActionGroups();
654 685
    void createMenus();
655 686
    void createToolBars();
656 687
    void createStatusBar();
657 688
    void setupConnections();
658 689
    void createLegend();
690
    void createTabWidget();
659 691
    void createOverview();
660
    void createCanvas();
661 692
    bool createDB();
662 693
    void createMapTips();
694
    QgsMapCanvas * createMapCanvasWithTools();
695
    void resetupConnections(QgsMapCanvas *thePrevMapCanvas, QgsLegend *thePrevMapLegend,
696
                            QgsMapCanvas *theNewMapCanvas, QgsLegend *theNewMapLegend);
663 697

  
664 698
    // toolbars ---------------------------------------
665 699
    QToolBar *mFileToolBar;
......
673 707
    // actions for menus and toolbars -----------------
674 708

  
675 709
    QAction *mActionNewProject;
710
    QAction *mActionNewTab;
711
    QAction *mActionCloseTab;
676 712
    QAction *mActionOpenProject;
677 713
    QAction *mActionFileSeparator1;
678 714
    QAction *mActionSaveProject;
......
798 834

  
799 835
    class Tools
800 836
    {
801
      public:
802
        QgsMapTool* mZoomIn;
803
        QgsMapTool* mZoomOut;
804
        QgsMapTool* mPan;
805
        QgsMapTool* mIdentify;
806
        QgsMapTool* mMeasureDist;
807
        QgsMapTool* mMeasureArea;
808
        QgsMapTool* mCapturePoint;
809
        QgsMapTool* mCaptureLine;
810
        QgsMapTool* mCapturePolygon;
811
        QgsMapTool* mMoveFeature;
812
        QgsMapTool* mSplitFeatures;
813
        QgsMapTool* mSelect;
814
        QgsMapTool* mVertexAdd;
815
        QgsMapTool* mVertexMove;
816
        QgsMapTool* mVertexDelete;
817
        QgsMapTool* mAddRing;
818
        QgsMapTool* mAddIsland;
819
    } mMapTools;
837
    public:
838
      ~Tools();
839
      QgsMapTool* mZoomIn;
840
      QgsMapTool* mZoomOut;
841
      QgsMapTool* mPan;
842
      QgsMapTool* mIdentify;
843
      QgsMapTool* mMeasureDist;
844
      QgsMapTool* mMeasureArea;
845
      QgsMapTool* mCapturePoint;
846
      QgsMapTool* mCaptureLine;
847
      QgsMapTool* mCapturePolygon;
848
      QgsMapTool* mMoveFeature;
849
      QgsMapTool* mSplitFeatures;
850
      QgsMapTool* mSelect;
851
      QgsMapTool* mVertexAdd;
852
      QgsMapTool* mVertexMove;
853
      QgsMapTool* mVertexDelete;
854
      QgsMapTool* mAddRing;
855
      QgsMapTool* mAddIsland;
856
      QgsMapTool* currentTool;
857
    } *mMapTools;
820 858

  
859
    Tools *mapTools() { return mMapTools; }
860

  
861
    //! List of map tools
862
    QList<Tools *> mMapToolsList;
863

  
821 864
    QgsMapTool *mNonEditMapTool;
822 865

  
823 866
    //! Widget that will live on the statusbar to display "scale 1:"
......
850 893
    QMenu *toolPopupCapture;
851 894
    //! Map canvas
852 895
    QgsMapCanvas *mMapCanvas;
896
    //! Map overview canvas
897
    QgsMapOverviewCanvas *mMapOverviewCanvas;
898
    //! List of map canvases
899
    QList<QgsMapCanvas *> mMapCanvasList;
900
    //! List of overviewcanvases
901
    QList<QgsMapOverviewCanvas *> mMapOverviewCanvasList;
902
    //! List of legends
903
    QList<QgsLegend *> mMapLegendList;
904
    //! Tab widget
905
    QgsTabWidget *mTabWidget;
853 906
    //! Table of contents (legend) for the map
854 907
    QgsLegend *mMapLegend;
855 908
    //! Cursor for the overview map
/usr/local/src/qgis/src/app/qgisapp.cpp (working copy)
129 129
#include "qgsrectangle.h"
130 130
#include "qgsrenderer.h"
131 131
#include "qgsserversourceselect.h"
132
#include "qgstabwidget.h"
132 133
#include "qgsvectordataprovider.h"
133 134
#include "qgsvectorlayer.h"
134 135
#include "ogr/qgsopenvectorlayerdialog.h"
......
306 307
// constructor starts here
307 308
QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
308 309
    : QMainWindow( parent, fl ),
310
    mLegendDock( NULL ),
311
    mOverviewDock( NULL ),
312
    mMapCanvas( NULL ),
313
    mMapLegend( NULL ),
314
    mOverviewMapCursor( NULL ),
309 315
    mSplash( splash ),
310 316
    mComposer( 0 ),
311 317
    mPythonConsole( NULL ),
......
344 350
  createMenus();
345 351
  createToolBars();
346 352
  createStatusBar();
347
  createCanvas();
353
  createTabWidget();
354
  twCreateNewTab();
348 355
  mMapCanvas->freeze();
349 356
  createLegend();
350 357
  createOverview();
351 358
  createMapTips();
359
  createActionsExt();
352 360
  readSettings();
353 361
  updateRecentProjectPaths();
354 362

  
......
449 457
  delete mInternalClipboard;
450 458
  delete mQgisInterface;
451 459

  
452
  delete mMapTools.mZoomIn;
453
  delete mMapTools.mZoomOut;
454
  delete mMapTools.mPan;
455
  delete mMapTools.mIdentify;
456
  delete mMapTools.mMeasureDist;
457
  delete mMapTools.mMeasureArea;
458
  delete mMapTools.mCapturePoint;
459
  delete mMapTools.mCaptureLine;
460
  delete mMapTools.mCapturePolygon;
461
  delete mMapTools.mMoveFeature;
462
  delete mMapTools.mSplitFeatures;
463
  delete mMapTools.mSelect;
464
  delete mMapTools.mVertexAdd;
465
  delete mMapTools.mVertexMove;
466
  delete mMapTools.mVertexDelete;
467
  delete mMapTools.mAddRing;
468
  delete mMapTools.mAddIsland;
460
  // call delete for all items from the lists
461
  qDeleteAll(mMapCanvasList);
462
  qDeleteAll(mMapOverviewCanvasList);
463
  qDeleteAll(mMapLegendList);
464
  qDeleteAll(mMapToolsList);
469 465

  
466
  // remove all items from the lists
467
  mMapCanvasList.clear();
468
  mMapOverviewCanvasList.clear();
469
  mMapLegendList.clear();
470
  mMapToolsList.clear();
471

  
470 472
  delete mPythonConsole;
471 473
  delete mPythonUtils;
472 474

  
......
536 538
  mActionNewProject->setStatusTip( tr( "New Project" ) );
537 539
  connect( mActionNewProject, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
538 540

  
541
  mActionNewTab = new QAction( getThemeIcon( "mActionNewTab.png" ), tr( "&New Tab" ), this );
542
//  mActionNewTab->setShortcut( tr( "Ctrl+T", "New Tab" ) );
543
  mActionNewTab->setShortcut( QKeySequence::AddTab );
544
  mActionNewTab->setStatusTip( tr( "New Tab" ) );
545
  connect( mActionNewTab, SIGNAL( triggered() ), this, SLOT( twCreateNewTab() ) );
546

  
547
  mActionCloseTab = new QAction( getThemeIcon( "mActionCloseTab.png" ), tr( "&Close Tab" ), this );
548
//  mActionCloseTab->setShortcut( tr( "Ctrl+W", "Close Tab" ) );
549
  mActionCloseTab->setShortcut( QKeySequence::Close );
550
  mActionCloseTab->setStatusTip( tr( "Close Tab" ) );
551
  connect( mActionCloseTab, SIGNAL( triggered() ), this, SLOT( twCloseTab() ) );
552

  
539 553
  mActionOpenProject = new QAction( getThemeIcon( "mActionFileOpen.png" ), tr( "&Open Project..." ), this );
540 554
  mActionOpenProject->setShortcut( tr( "Ctrl+O", "Open a Project" ) );
541 555
  mActionOpenProject->setStatusTip( tr( "Open a Project" ) );
......
937 951
  connect( mActionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
938 952
}
939 953

  
954
void QgisApp::createActionsExt()
955
{
956
  // create actions that helps user to navigate in tabs
957
  QAction *myActionNextTab = new QAction(this);
958
//  myActionNextTab->setShortcut(tr("Ctrl+PgDown", "Goto next tab"));
959
  myActionNextTab->setShortcut(QKeySequence::NextChild);
960
  connect(myActionNextTab, SIGNAL(triggered()), mTabWidget, SLOT(nextTab()));
961
  addAction(myActionNextTab);
962

  
963
  QAction *myActionPreviousTab = new QAction(this);
964
//  myActionPrevTab->setShortcut(tr("Ctrl+PgUp", "Goto previous tab"));
965
  myActionPreviousTab->setShortcut(QKeySequence::PreviousChild);
966
  connect(myActionPreviousTab, SIGNAL(triggered()), mTabWidget, SLOT(previousTab()));
967
  addAction(myActionPreviousTab);
968
}
969

  
940 970
void QgisApp::showPythonDialog()
941 971
{
942 972
  if ( !mPythonUtils || !mPythonUtils->isEnabled() )
......
1023 1053
  mFileMenu = menuBar()->addMenu( tr( "&File" ) );
1024 1054

  
1025 1055
  mFileMenu->addAction( mActionNewProject );
1056
  mFileMenu->addAction(mActionNewTab);
1026 1057
  mFileMenu->addAction( mActionOpenProject );
1027 1058
  mRecentProjectsMenu = mFileMenu->addMenu( tr( "&Open Recent Projects" ) );
1028 1059
  // Connect once for the entire submenu.
......
1044 1075
  mFileMenu->addAction( mActionPrintComposer );
1045 1076
  mActionFileSeparator4 = mFileMenu->addSeparator();
1046 1077

  
1078
  mFileMenu->addAction(mActionCloseTab);
1047 1079
  mFileMenu->addAction( mActionExit );
1048 1080

  
1049 1081
  // Edit Menu
......
1449 1481
  QgsApplication::setThemeName( theThemeName );
1450 1482
  //QgsDebugMsg("Setting theme to \n" + theThemeName);
1451 1483
  mActionNewProject->setIcon( getThemeIcon( "/mActionFileNew.png" ) );
1484
  mActionNewTab->setIcon( getThemeIcon( "/mActionNewTab.png" ) );
1452 1485
  mActionOpenProject->setIcon( getThemeIcon( "/mActionFileOpen.png" ) );
1453 1486
  mActionSaveProject->setIcon( getThemeIcon( "/mActionFileSave.png" ) );
1454 1487
  mActionSaveProjectAs->setIcon( getThemeIcon( "/mActionFileSaveAs.png" ) );
1455 1488
  mActionPrintComposer->setIcon( getThemeIcon( "/mActionFilePrint.png" ) );
1456 1489
  mActionSaveMapAsImage->setIcon( getThemeIcon( "/mActionSaveMapAsImage.png" ) );
1490
  mActionCloseTab->setIcon( getThemeIcon( "/mActionCloseTab.png" ) );
1457 1491
  mActionExit->setIcon( getThemeIcon( "/mActionFileExit.png" ) );
1458 1492
  mActionAddOgrLayer->setIcon( getThemeIcon( "/mActionAddOgrLayer.png" ) );
1459 1493
  mActionAddRasterLayer->setIcon( getThemeIcon( "/mActionAddRasterLayer.png" ) );
......
1516 1550
  emit currentThemeChanged( theThemeName );
1517 1551
}
1518 1552

  
1553
void QgisApp::resetupConnections(QgsMapCanvas *thePrevMapCanvas, QgsLegend *thePrevMapLegend,
1554
                                 QgsMapCanvas *theNewMapCanvas, QgsLegend *theNewMapLegend)
1555
{
1556
  if (thePrevMapCanvas && thePrevMapLegend)
1557
  {
1558
    // disconnect map layer registry signals to legend
1559
    disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ),
1560
                thePrevMapLegend, SLOT( removeLayer( QString ) ) );
1561
    disconnect( QgsMapLayerRegistry::instance(), SIGNAL( removedAll() ),
1562
                thePrevMapLegend, SLOT( removeAll() ) );
1563
    disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ),
1564
                thePrevMapLegend, SLOT( addLayer( QgsMapLayer * ) ) );
1565
    disconnect( thePrevMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
1566
                this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer* ) ) );
1567

  
1568
    //signal when mouse moved over window (coords display in status bar)
1569
    disconnect( thePrevMapCanvas, SIGNAL( xyCoordinates( QgsPoint & ) ), this, SLOT( showMouseCoordinate( QgsPoint & ) ) );
1570
    disconnect( thePrevMapCanvas->mapRenderer(), SIGNAL( drawingProgress( int, int ) ), this, SLOT( showProgress( int, int ) ) );
1571
    disconnect( thePrevMapCanvas->mapRenderer(), SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( hasCrsTransformEnabled( bool ) ) );
1572
    disconnect( thePrevMapCanvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( destinationSrsChanged() ) );
1573
    disconnect( thePrevMapCanvas, SIGNAL( extentsChanged() ), this, SLOT( showExtents() ) );
1574
    disconnect( thePrevMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( showScale( double ) ) );
1575
    disconnect( thePrevMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( updateMouseCoordinatePrecision() ) );
1576
    disconnect( thePrevMapCanvas, SIGNAL( mapToolSet( QgsMapTool * ) ), this, SLOT( mapToolChanged( QgsMapTool * ) ) );
1577
    disconnect( thePrevMapCanvas, SIGNAL( selectionChanged( QgsMapLayer * ) ),
1578
                this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer * ) ) );
1579

  
1580
    disconnect( mRenderSuppressionCBox, SIGNAL( toggled( bool ) ), thePrevMapCanvas, SLOT( setRenderFlag( bool ) ) );
1581
  }
1582

  
1583
  if (theNewMapCanvas && theNewMapLegend)
1584
  {
1585
    // connect map layer registry signals to legend
1586
    connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ),
1587
             theNewMapLegend, SLOT( removeLayer( QString ) ) );
1588
    connect( QgsMapLayerRegistry::instance(), SIGNAL( removedAll() ),
1589
             theNewMapLegend, SLOT( removeAll() ) );
1590
    connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ),
1591
             theNewMapLegend, SLOT( addLayer( QgsMapLayer * ) ) );
1592
    connect( theNewMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
1593
             this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer* ) ) );
1594

  
1595

  
1596
    //signal when mouse moved over window (coords display in status bar)
1597
    connect( theNewMapCanvas, SIGNAL( xyCoordinates( QgsPoint & ) ), this, SLOT( showMouseCoordinate( QgsPoint & ) ) );
1598
    connect( theNewMapCanvas->mapRenderer(), SIGNAL( drawingProgress( int, int ) ), this, SLOT( showProgress( int, int ) ) );
1599
    connect( theNewMapCanvas->mapRenderer(), SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( hasCrsTransformEnabled( bool ) ) );
1600
    connect( theNewMapCanvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( destinationSrsChanged() ) );
1601
    connect( theNewMapCanvas, SIGNAL( extentsChanged() ), this, SLOT( showExtents() ) );
1602
    connect( theNewMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( showScale( double ) ) );
1603
    connect( theNewMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( updateMouseCoordinatePrecision() ) );
1604
    connect( theNewMapCanvas, SIGNAL( mapToolSet( QgsMapTool * ) ), this, SLOT( mapToolChanged( QgsMapTool * ) ) );
1605
    connect( theNewMapCanvas, SIGNAL( selectionChanged( QgsMapLayer * ) ),
1606
             this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer * ) ) );
1607

  
1608
    connect( mRenderSuppressionCBox, SIGNAL( toggled( bool ) ), theNewMapCanvas, SLOT( setRenderFlag( bool ) ) );
1609
  }
1610
}
1611

  
1519 1612
void QgisApp::setupConnections()
1520 1613
{
1521 1614
  // connect the "cleanup" slot
1522 1615
  connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( saveWindowState() ) );
1523
  //connect the legend, mapcanvas and overview canvas to the registry
1616
  // connect the legend, mapcanvas and overview canvas to the registry
1524 1617

  
1525
  // connect map layer registry signals to legend
1526
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ),
1527
           mMapLegend, SLOT( removeLayer( QString ) ) );
1528
  connect( QgsMapLayerRegistry::instance(), SIGNAL( removedAll() ),
1529
           mMapLegend, SLOT( removeAll() ) );
1530
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ),
1531
           mMapLegend, SLOT( addLayer( QgsMapLayer * ) ) );
1532
  connect( mMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
1533
           this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer* ) ) );
1534

  
1535

  
1536
  //signal when mouse moved over window (coords display in status bar)
1537
  connect( mMapCanvas, SIGNAL( xyCoordinates( QgsPoint & ) ), this, SLOT( showMouseCoordinate( QgsPoint & ) ) );
1538
  connect( mMapCanvas->mapRenderer(), SIGNAL( drawingProgress( int, int ) ), this, SLOT( showProgress( int, int ) ) );
1539
  connect( mMapCanvas->mapRenderer(), SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( hasCrsTransformEnabled( bool ) ) );
1540
  connect( mMapCanvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( destinationSrsChanged() ) );
1541
  connect( mMapCanvas, SIGNAL( extentsChanged() ), this, SLOT( showExtents() ) );
1542
  connect( mMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( showScale( double ) ) );
1543
  connect( mMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( updateMouseCoordinatePrecision() ) );
1544
  connect( mMapCanvas, SIGNAL( mapToolSet( QgsMapTool * ) ), this, SLOT( mapToolChanged( QgsMapTool * ) ) );
1545
  connect( mMapCanvas, SIGNAL( selectionChanged( QgsMapLayer * ) ),
1546
           this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer * ) ) );
1547

  
1548
  connect( mRenderSuppressionCBox, SIGNAL( toggled( bool ) ), mMapCanvas, SLOT( setRenderFlag( bool ) ) );
1549 1618
  //
1550 1619
  // Do we really need this ??? - its already connected to the esc key...TS
1551 1620
  //
......
1555 1624
  connect( QgsProject::instance(), SIGNAL( oldProjectVersionWarning( QString ) ),
1556 1625
           this, SLOT( oldProjectVersionWarning( QString ) ) );
1557 1626

  
1627
  // do something when current tab in tab widget was switched or moved
1628
  connect( mTabWidget, SIGNAL(currentChanged(int)), this, SLOT(twCurrentTabChanged(int)));
1629
  connect( mTabWidget, SIGNAL(tabMoved(int,int)), this, SLOT(twCurrentTabMoved(int, int)));
1630

  
1631
  // close a current tab when the close button on a tab is clicked
1632
  connect( mTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(twCloseTab(int)));
1558 1633
}
1559
void QgisApp::createCanvas()
1634

  
1635
void QgisApp::twCurrentTabChanged(int index)
1560 1636
{
1637
  // get new map canvas and legend from lists
1638
  QgsMapCanvas *pNewMapCanvas = mMapCanvasList.at(index);
1639
  QgsLegend *pNewMapLegend = mMapLegendList.at(index);
1640

  
1641
  // do nothing if new map canvas and legend is current
1642
  if (pNewMapCanvas == mMapCanvas && pNewMapLegend == mMapLegend) return;
1643

  
1644
  // setup connections for new map canvas and legend selected in a tab
1645
  // and disconnect connections for previous map canvas and legend
1646
  if (pNewMapCanvas && pNewMapLegend)
1647
  {
1648
    resetupConnections(mMapCanvas, mMapLegend, pNewMapCanvas, pNewMapLegend);
1649
  }
1650

  
1651
  // set new map canvas, overview, legend and tools for a selected tab
1652
  mMapCanvas = pNewMapCanvas;
1653
  mMapLegend = pNewMapLegend;
1654
  mMapOverviewCanvas = mMapOverviewCanvasList.at(index);
1655
  mMapTools = mMapToolsList.at(index);
1656

  
1657
  // enable overview canvas for map canvas
1658
  mMapCanvas->enableOverviewMode( mMapOverviewCanvas );
1659
  // set map tool for map canvas
1660
  mMapCanvas->setMapTool( mMapToolsList.at(index)->currentTool );
1661

  
1662
  // put new map legend in legend dock widget and new overview canvas to overview dock
1663
  if (mLegendDock && mOverviewDock)
1664
  {
1665
    mLegendDock->setWidget(mMapLegend);
1666
    mOverviewDock->setWidget(mMapOverviewCanvas);
1667
  }
1668
}
1669

  
1670
void QgisApp::twCurrentTabMoved(int from, int to)
1671
{
1672
  // do appropriated procedures to change an index of the current tab to new one
1673
  twCurrentTabChanged(to);
1674

  
1675
  // do the swap in lists
1676
  mMapCanvasList.swap(from, to);
1677
  mMapOverviewCanvasList.swap(from,to);
1678
  mMapLegendList.swap(from, to);
1679
  mMapToolsList.swap(from, to);
1680
}
1681

  
1682
void QgisApp::twCreateNewTab()
1683
{
1684
  // countOfTabs counts all numbers of created tabs and put it in a name of a new tab
1685
  static int countOfTabs = 1;
1686

  
1687
  // create map canvas and add it to the tab widget
1688
  QgsMapCanvas *myMapCanvas = createMapCanvasWithTools();
1689
  myMapCanvas->setObjectName( "theMapCanvas" );
1690
  mTabWidget->addTab(myMapCanvas, tr("Canvas %1").arg(countOfTabs++));
1691

  
1692
  // set canvas color in map canvas
1693
  int  myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorRedPart", 255 );
1694
  int  myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorGreenPart", 255 );
1695
  int  myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorBluePart", 255 );
1696
  QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt );
1697
  myMapCanvas->setCanvasColor( myColor ); // this is fill colour before rendering onto canvas
1698

  
1699
  // create map legend for map canvas
1700
  QgsLegend *myMapLegend = new QgsLegend( NULL, "theMapLegend" );
1701
  myMapLegend->setObjectName( "theMapLegend" );
1702
  myMapLegend->setMapCanvas( myMapCanvas );
1703

  
1704
  // add the toggle editing action also to legend such that right click menu and button show the same state
1705
  myMapLegend->setToggleEditingAction( mActionToggleEditing );
1706
  myMapLegend->setWhatsThis( tr( "Map legend that displays all the layers currently on the map canvas."
1707
                                 "Click on the check box to turn a layer on or off. Double click on a layer"
1708
                                 "in the legend to customize its appearance and set other properties." ) );
1709

  
1710
  // create overview canvas
1711
  QgsMapOverviewCanvas* myMapOverviewCanvas = new QgsMapOverviewCanvas( NULL, myMapCanvas );
1712
  myMapOverviewCanvas->setWhatsThis( tr( "Map overview canvas. This canvas can be used to display a locator map"
1713
                                         "that shows the current extent of the map canvas. The current extent is shown as"
1714
                                         "a red rectangle. Any layer on the map can be added to the overview canvas." ) );
1715

  
1716
  // set cursor in overview canvas
1717
  if (!mOverviewMapCursor)
1718
  {
1719
    QBitmap overviewPanBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
1720
    QBitmap overviewPanBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
1721

  
1722
    //set upper left corner as hot spot - this is better when extent marker is small; hand won't cover the marker
1723
    mOverviewMapCursor = new QCursor( overviewPanBmp, overviewPanBmpMask, 0, 0 );
1724
  }
1725
  myMapOverviewCanvas->setCursor( *mOverviewMapCursor );
1726

  
1727
  // append map canvas, overview canvas and legend to list
1728
  mMapCanvasList.append(myMapCanvas);
1729
  mMapOverviewCanvasList.append(myMapOverviewCanvas);
1730
  mMapLegendList.append(myMapLegend);
1731

  
1732
  // set map canvas and map tools for new tab
1733
  twCurrentTabChanged(mTabWidget->currentIndex());
1734
}
1735

  
1736
void QgisApp::twCloseTab()
1737
{
1738
  // close the current tab
1739
  twCloseTab(mTabWidget->currentIndex());
1740
}
1741

  
1742
void QgisApp::twCloseTab(int index)
1743
{
1744
  // do nothing when we have an one tab
1745
  if (mTabWidget->count() == 1) return;
1746

  
1747
  // remove current tab
1748
  mTabWidget->removeTab(index);
1749

  
1750
  QgsMapCanvas *ptmpMapCanvas = mMapCanvasList[index];
1751
  QgsLegend *ptmpMapLegend = mMapLegendList[index];
1752

  
1753
  // disconnect the connetions relative to the map canvas and legend at index *index*
1754
  resetupConnections(ptmpMapCanvas, ptmpMapLegend, NULL, NULL);
1755

  
1756
  // free memory allocated by tems corresponding to the current tab
1757
  delete mMapToolsList[index];
1758
  delete mMapOverviewCanvasList[index];
1759
  delete ptmpMapLegend;
1760
  delete ptmpMapCanvas;
1761

  
1762
  // set the pointers to NULL
1763
  mMapCanvas = NULL;
1764
  mMapOverviewCanvas = NULL;
1765
  mMapLegend = NULL;
1766
  mMapTools = NULL;
1767

  
1768
  // remove corresponding to current tab map canvas, overview canvas, map legend and map tools
1769
  mMapCanvasList.removeAt(index);
1770
  mMapOverviewCanvasList.removeAt(index);
1771
  mMapLegendList.removeAt(index);
1772
  mMapToolsList.removeAt(index);
1773

  
1774
  // *update* the current tab
1775
  twCurrentTabChanged(mTabWidget->currentIndex());
1776
}
1777

  
1778
void QgisApp::createTabWidget()
1779
{
1780
  // create the main tab widget
1781
  mTabWidget = new QgsTabWidget(this);
1782
  mTabWidget->setTabPosition(QTabWidget::East);
1783
  mTabWidget->setTabsClosable(true);
1784
  mTabWidget->setMovable(true);
1785
  setCentralWidget( mTabWidget );
1786
}
1787

  
1788
QgsMapCanvas * QgisApp::createMapCanvasWithTools()
1789
{
1561 1790
  // "theMapCanvas" used to find this canonical instance later
1562
  mMapCanvas = new QgsMapCanvas( this, "theMapCanvas" );
1563
  mMapCanvas->setWhatsThis( tr( "Map canvas. This is where raster and vector "
1791
  QgsMapCanvas *myMapCanvas = new QgsMapCanvas( this, "theMapCanvas" );
1792
  myMapCanvas->setWhatsThis( tr( "Map canvas. This is where raster and vector "
1564 1793
                                "layers are displayed when added to the map" ) );
1565 1794

  
1566
  setCentralWidget( mMapCanvas );
1567 1795
  // set the focus to the map canvas
1568
  mMapCanvas->setFocus();
1796
  myMapCanvas->setFocus();
1569 1797

  
1570 1798
  // create tools
1571
  mMapTools.mZoomIn = new QgsMapToolZoom( mMapCanvas, FALSE /* zoomIn */ );
1572
  mMapTools.mZoomIn->setAction( mActionZoomIn );
1573
  mMapTools.mZoomOut = new QgsMapToolZoom( mMapCanvas, TRUE /* zoomOut */ );
1574
  mMapTools.mZoomOut->setAction( mActionZoomOut );
1575
  mMapTools.mPan = new QgsMapToolPan( mMapCanvas );
1576
  mMapTools.mPan->setAction( mActionPan );
1577
  mMapTools.mIdentify = new QgsMapToolIdentify( mMapCanvas );
1578
  mMapTools.mIdentify->setAction( mActionIdentify );
1579
  mMapTools.mMeasureDist = new QgsMeasureTool( mMapCanvas, FALSE /* area */ );
1580
  mMapTools.mMeasureDist->setAction( mActionMeasure );
1581
  mMapTools.mMeasureArea = new QgsMeasureTool( mMapCanvas, TRUE /* area */ );
1582
  mMapTools.mMeasureArea->setAction( mActionMeasureArea );
1583
  mMapTools.mCapturePoint = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CapturePoint );
1584
  mMapTools.mCapturePoint->setAction( mActionCapturePoint );
1799
  mMapTools = new Tools();
1800

  
1801
  mMapTools->mZoomIn = new QgsMapToolZoom( myMapCanvas, FALSE /* zoomIn */ );
1802
  mMapTools->mZoomIn->setAction( mActionZoomIn );
1803
  mMapTools->mZoomOut = new QgsMapToolZoom( myMapCanvas, TRUE /* zoomOut */ );
1804
  mMapTools->mZoomOut->setAction( mActionZoomOut );
1805
  mMapTools->mPan = new QgsMapToolPan( myMapCanvas );
1806
  mMapTools->mPan->setAction( mActionPan );
1807
  mMapTools->mIdentify = new QgsMapToolIdentify( myMapCanvas );
1808
  mMapTools->mIdentify->setAction( mActionIdentify );
1809
  mMapTools->mMeasureDist = new QgsMeasureTool( myMapCanvas, FALSE /* area */ );
1810
  mMapTools->mMeasureDist->setAction( mActionMeasure );
1811
  mMapTools->mMeasureArea = new QgsMeasureTool( myMapCanvas, TRUE /* area */ );
1812
  mMapTools->mMeasureArea->setAction( mActionMeasureArea );
1813
  mMapTools->mCapturePoint = new QgsMapToolAddFeature( myMapCanvas, QgsMapToolCapture::CapturePoint );
1814
  mMapTools->mCapturePoint->setAction( mActionCapturePoint );
1585 1815
  mActionCapturePoint->setVisible( false );
1586
  mMapTools.mCaptureLine = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CaptureLine );
1587
  mMapTools.mCaptureLine->setAction( mActionCaptureLine );
1816
  mMapTools->mCaptureLine = new QgsMapToolAddFeature( myMapCanvas, QgsMapToolCapture::CaptureLine );
1817
  mMapTools->mCaptureLine->setAction( mActionCaptureLine );
1588 1818
  mActionCaptureLine->setVisible( false );
1589
  mMapTools.mCapturePolygon = new QgsMapToolAddFeature( mMapCanvas, QgsMapToolCapture::CapturePolygon );
1590
  mMapTools.mCapturePolygon->setAction( mActionCapturePolygon );
1819
  mMapTools->mCapturePolygon = new QgsMapToolAddFeature( myMapCanvas, QgsMapToolCapture::CapturePolygon );
1820
  mMapTools->mCapturePolygon->setAction( mActionCapturePolygon );
1591 1821
  mActionCapturePolygon->setVisible( false );
1592
  mMapTools.mMoveFeature = new QgsMapToolMoveFeature( mMapCanvas );
1593
  mMapTools.mMoveFeature->setAction( mActionMoveFeature );
1594
  mMapTools.mSplitFeatures = new QgsMapToolSplitFeatures( mMapCanvas );
1595
  mMapTools.mSplitFeatures->setAction( mActionSplitFeatures );
1596
  mMapTools.mSelect = new QgsMapToolSelect( mMapCanvas );
1597
  mMapTools.mSelect->setAction( mActionSelect );
1598
  mMapTools.mVertexAdd = new QgsMapToolAddVertex( mMapCanvas );
1599
  mMapTools.mVertexAdd->setAction( mActionAddVertex );
1600
  mMapTools.mVertexMove = new QgsMapToolMoveVertex( mMapCanvas );
1601
  mMapTools.mVertexMove->setAction( mActionMoveVertex );
1602
  mMapTools.mVertexDelete = new QgsMapToolDeleteVertex( mMapCanvas );
1603
  mMapTools.mVertexDelete->setAction( mActionDeleteVertex );
1604
  mMapTools.mAddRing = new QgsMapToolAddRing( mMapCanvas );
1605
  mMapTools.mAddRing->setAction( mActionAddRing );
1606
  mMapTools.mAddIsland = new QgsMapToolAddIsland( mMapCanvas );
1822
  mMapTools->mMoveFeature = new QgsMapToolMoveFeature( myMapCanvas );
1823
  mMapTools->mMoveFeature->setAction( mActionMoveFeature );
1824
  mMapTools->mSplitFeatures = new QgsMapToolSplitFeatures( myMapCanvas );
1825
  mMapTools->mSplitFeatures->setAction( mActionSplitFeatures );
1826
  mMapTools->mSelect = new QgsMapToolSelect( myMapCanvas );
1827
  mMapTools->mSelect->setAction( mActionSelect );
1828
  mMapTools->mVertexAdd = new QgsMapToolAddVertex( myMapCanvas );
1829
  mMapTools->mVertexAdd->setAction( mActionAddVertex );
1830
  mMapTools->mVertexMove = new QgsMapToolMoveVertex( myMapCanvas );
1831
  mMapTools->mVertexMove->setAction( mActionMoveVertex );
1832
  mMapTools->mVertexDelete = new QgsMapToolDeleteVertex( myMapCanvas );
1833
  mMapTools->mVertexDelete->setAction( mActionDeleteVertex );
1834
  mMapTools->mAddRing = new QgsMapToolAddRing( myMapCanvas );
1835
  mMapTools->mAddRing->setAction( mActionAddRing );
1836
  mMapTools->mAddIsland = new QgsMapToolAddIsland( myMapCanvas );
1837

  
1838
  // set a current map tool
1839
  mMapTools->currentTool = mMapTools->mPan;
1840

  
1607 1841
  //ensure that non edit tool is initialised or we will get crashes in some situations
1608
  mNonEditMapTool = mMapTools.mPan;
1842
  mNonEditMapTool = mMapTools->mPan;
1843

  
1844
  // append map tools to list
1845
  mMapToolsList.append(mMapTools);
1846

  
1847
  return myMapCanvas;
1609 1848
}
1610 1849

  
1611 1850
void QgisApp::createOverview()
1612 1851
{
1613
  // overview canvas
1614
  QgsMapOverviewCanvas* overviewCanvas = new QgsMapOverviewCanvas( NULL, mMapCanvas );
1615
  overviewCanvas->setWhatsThis( tr( "Map overview canvas. This canvas can be used to display a locator map that shows the current extent of the map canvas. The current extent is shown as a red rectangle. Any layer on the map can be added to the overview canvas." ) );
1616

  
1617
  QBitmap overviewPanBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
1618
  QBitmap overviewPanBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
1619
  mOverviewMapCursor = new QCursor( overviewPanBmp, overviewPanBmpMask, 0, 0 ); //set upper left corner as hot spot - this is better when extent marker is small; hand won't cover the marker
1620
  overviewCanvas->setCursor( *mOverviewMapCursor );
1621
//  QVBoxLayout *myOverviewLayout = new QVBoxLayout;
1622
//  myOverviewLayout->addWidget(overviewCanvas);
1623
//  overviewFrame->setLayout(myOverviewLayout);
1624 1852
  mOverviewDock = new QDockWidget( tr( "Overview" ), this );
1625 1853
  mOverviewDock->setObjectName( "Overview" );
1626 1854
  mOverviewDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
1627
  mOverviewDock->setWidget( overviewCanvas );
1855
  mOverviewDock->setWidget( mMapOverviewCanvas );
1628 1856
  addDockWidget( Qt::LeftDockWidgetArea, mOverviewDock );
1629 1857
  // add to the Panel submenu
1630 1858
  mPanelMenu->addAction( mOverviewDock->toggleViewAction() );
1631 1859

  
1632
  mMapCanvas->enableOverviewMode( overviewCanvas );
1633

  
1634 1860
  // moved here to set anti aliasing to both map canvas and overview
1635 1861
  QSettings mySettings;
1636 1862
  mMapCanvas->enableAntiAliasing( mySettings.value( "/qgis/enable_anti_aliasing", false ).toBool() );
......
1659 1885
  mMapCanvas->refresh();
1660 1886
}
1661 1887

  
1888
void QgisApp::addTabWidget( QWidget *page, const QString &label )
1889
{
1890
  mTabWidget->addTab( page, label );
1891
}
1892

  
1893
void QgisApp::addTabWidget( QWidget *page, const QIcon &icon, const QString &label )
1894
{
1895
  mTabWidget->addTab( page, icon, label );
1896
}
1897

  
1898
void QgisApp::insertTabWidget( int index, QWidget *page, const QString &label )
1899
{
1900
  mTabWidget->insertTab( index, page, label );
1901
}
1902

  
1903
void QgisApp::insertTabWidget( int index, QWidget *page, const QIcon &icon, const QString &label )
1904
{
1905
  mTabWidget->insertTab( index, page, icon, label );
1906
}
1907

  
1908
void QgisApp::removeTabWidget( int index )
1909
{
1910
  mTabWidget->removeTab( index );
1911
}
1912

  
1662 1913
QToolBar *QgisApp::addToolBar( QString name )
1663 1914
{
1664 1915
  QToolBar *toolBar = QMainWindow::addToolBar( name );
......
1669 1920

  
1670 1921
void QgisApp::createLegend()
1671 1922
{
1672
  //legend
1673
  mMapLegend = new QgsLegend( NULL, "theMapLegend" );
1674
  mMapLegend->setObjectName( "theMapLegend" );
1675
  mMapLegend->setMapCanvas( mMapCanvas );
1676

  
1677
  //add the toggle editing action also to legend such that right click menu and button show the same state
1678
  mMapLegend->setToggleEditingAction( mActionToggleEditing );
1679

  
1680
  mMapLegend->setWhatsThis( tr( "Map legend that displays all the layers currently on the map canvas. Click on the check box to turn a layer on or off. Double click on a layer in the legend to customize its appearance and set other properties." ) );
1681 1923
  mLegendDock = new QDockWidget( tr( "Layers" ), this );
1682 1924
  mLegendDock->setObjectName( "Legend" );
1683 1925
  mLegendDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
......
2960 3202
  mMapCanvas->mapRenderer()->setProjectionsEnabled( FALSE );
2961 3203

  
2962 3204
  // set the initial map tool
2963
  mMapCanvas->setMapTool( mMapTools.mPan );
2964
  mNonEditMapTool = mMapTools.mPan;  // signals are not yet setup to catch this
3205
  mMapCanvas->setMapTool( mMapTools->mPan );
3206
  mNonEditMapTool = mMapTools->mPan;  // signals are not yet setup to catch this
2965 3207
} // QgisApp::fileNew(bool thePromptToSaveFlag)
2966 3208

  
2967 3209

  
......
3703 3945
      // showMaxmized() is a work-around. Turn off rendering for this as it
3704 3946
      // would otherwise cause two re-renders of the map, which can take a
3705 3947
      // long time.
3706
      bool renderFlag = mapCanvas()->renderFlag();
3707
      mapCanvas()->setRenderFlag( false );
3948
      bool renderFlag = mMapCanvas->renderFlag();
3949
      mMapCanvas->setRenderFlag( false );
3708 3950
      showNormal();
3709 3951
      showMaximized();
3710
      mapCanvas()->setRenderFlag( renderFlag );
3952
      mMapCanvas->setRenderFlag( renderFlag );
3711 3953
      mPrevScreenModeMaximized = false;
3712 3954
    }
3713 3955
    else
......
3802 4044
{
3803 4045
  QgsDebugMsg( "hiding all layers!" );
3804 4046

  
3805
  legend()->selectAll( false );
4047
  mMapLegend->selectAll( false );
3806 4048
}
3807 4049

  
3808 4050

  
......
3811 4053
{
3812 4054
  QgsDebugMsg( "Showing all layers!" );
3813 4055

  
3814
  legend()->selectAll( true );
4056
  mMapLegend->selectAll( true );
3815 4057
}
3816 4058

  
3817 4059

  
......
3819 4061
{
3820 4062
  QgsDebugMsg( "Setting map tool to zoomIn" );
3821 4063

  
3822
  mMapCanvas->setMapTool( mMapTools.mZoomIn );
4064
  mMapCanvas->setMapTool( mMapTools->mZoomIn );
3823 4065

  
3824 4066
  // notify the project we've made a change
3825 4067
  QgsProject::instance()->dirty( true );
......
3828 4070

  
3829 4071
void QgisApp::zoomOut()
3830 4072
{
3831
  mMapCanvas->setMapTool( mMapTools.mZoomOut );
4073
  mMapCanvas->setMapTool( mMapTools->mZoomOut );
3832 4074

  
3833 4075
  // notify the project we've made a change
3834 4076
  QgsProject::instance()->dirty( true );
......
3844 4086

  
3845 4087
void QgisApp::pan()
3846 4088
{
3847
  mMapCanvas->setMapTool( mMapTools.mPan );
4089
  mMapCanvas->setMapTool( mMapTools->mPan );
3848 4090
}
3849 4091

  
3850 4092
void QgisApp::zoomFull()
......
3878 4120

  
3879 4121
void QgisApp::identify()
3880 4122
{
3881
  mMapCanvas->setMapTool( mMapTools.mIdentify );
4123
  mMapCanvas->setMapTool( mMapTools->mIdentify );
3882 4124
}
3883 4125

  
3884 4126
void QgisApp::measure()
3885 4127
{
3886
  mMapCanvas->setMapTool( mMapTools.mMeasureDist );
4128
  mMapCanvas->setMapTool( mMapTools->mMeasureDist );
3887 4129
}
3888 4130

  
3889 4131
void QgisApp::measureArea()
3890 4132
{
3891
  mMapCanvas->setMapTool( mMapTools.mMeasureArea );
4133
  mMapCanvas->setMapTool( mMapTools->mMeasureArea );
3892 4134
}
3893 4135

  
3894 4136
void QgisApp::attributeTable()
......
3971 4213

  
3972 4214
void QgisApp::moveFeature()
3973 4215
{
3974
  mMapCanvas->setMapTool( mMapTools.mMoveFeature );
4216
  mMapCanvas->setMapTool( mMapTools->mMoveFeature );
3975 4217
}
3976 4218

  
3977 4219
void QgisApp::splitFeatures()
3978 4220
{
3979
  mMapCanvas->setMapTool( mMapTools.mSplitFeatures );
4221
  mMapCanvas->setMapTool( mMapTools->mSplitFeatures );
3980 4222
}
3981 4223

  
3982 4224
void QgisApp::capturePoint()
......
3987 4229
  }
3988 4230

  
3989 4231
  // set current map tool to select
3990
  mMapCanvas->setMapTool( mMapTools.mCapturePoint );
4232
  mMapCanvas->setMapTool( mMapTools->mCapturePoint );
3991 4233
}
3992 4234

  
3993 4235
void QgisApp::captureLine()
......
3997 4239
    return;
3998 4240
  }
3999 4241

  
4000
  mMapCanvas->setMapTool( mMapTools.mCaptureLine );
4242
  mMapCanvas->setMapTool( mMapTools->mCaptureLine );
4001 4243
}
4002 4244

  
4003 4245
void QgisApp::capturePolygon()
......
4006 4248
  {
4007 4249
    return;
4008 4250
  }
4009
  mMapCanvas->setMapTool( mMapTools.mCapturePolygon );
4251
  mMapCanvas->setMapTool( mMapTools->mCapturePolygon );
4010 4252
}
4011 4253

  
4012 4254
void QgisApp::select()
4013 4255
{
4014
  mMapCanvas->setMapTool( mMapTools.mSelect );
4256
  mMapCanvas->setMapTool( mMapTools->mSelect );
4015 4257
}
4016 4258

  
4017 4259

  
......
4021 4263
  {
4022 4264
    return;
4023 4265
  }
4024
  mMapCanvas->setMapTool( mMapTools.mVertexAdd );
4266
  mMapCanvas->setMapTool( mMapTools->mVertexAdd );
4025 4267

  
4026 4268
}
4027 4269

  
......
4031 4273
  {
4032 4274
    return;
4033 4275
  }
4034
  mMapCanvas->setMapTool( mMapTools.mVertexMove );
4276
  mMapCanvas->setMapTool( mMapTools->mVertexMove );
4035 4277
}
4036 4278

  
4037 4279
void QgisApp::addRing()
......
4040 4282
  {
4041 4283
    return;
4042 4284
  }
4043
  mMapCanvas->setMapTool( mMapTools.mAddRing );
4285
  mMapCanvas->setMapTool( mMapTools->mAddRing );
4044 4286
}
4045 4287

  
4046 4288
void QgisApp::addIsland()
......
4049 4291
  {
4050 4292
    return;
4051 4293
  }
4052
  mMapCanvas->setMapTool( mMapTools.mAddIsland );
4294
  mMapCanvas->setMapTool( mMapTools->mAddIsland );
4053 4295
}
4054 4296

  
4055 4297

  
......
4059 4301
  {
4060 4302
    return;
4061 4303
  }
4062
  mMapCanvas->setMapTool( mMapTools.mVertexDelete );
4304
  mMapCanvas->setMapTool( mMapTools->mVertexDelete );
4063 4305
}
4064 4306

  
4065 4307

  
......
4937 5179

  
4938 5180
void QgisApp::mapToolChanged( QgsMapTool *tool )
4939 5181
{
4940
  if ( tool && !tool->isEditTool() )
5182
  if ( tool )
4941 5183
  {
4942
    mNonEditMapTool = tool;
5184
    if ( !tool->isEditTool() )
5185
    {
5186
      mNonEditMapTool = tool;
5187
    }
5188
    mMapTools->currentTool = tool;
4943 5189
  }
4944 5190
}
4945 5191

  
......
4994 5240
    // coordinates with the aim of always having enough decimal places
4995 5241
    // to show the difference in position between adjacent pixels.
4996 5242
    // Also avoid taking the log of 0.
4997
    if ( mapCanvas()->mapUnitsPerPixel() != 0.0 )
4998
      dp = static_cast<int>( ceil( -1.0 * log10( mapCanvas()->mapUnitsPerPixel() ) ) );
5243
    if ( mMapCanvas->mapUnitsPerPixel() != 0.0 )
5244
      dp = static_cast<int>( ceil( -1.0 * log10( mMapCanvas->mapUnitsPerPixel() ) ) );
4999 5245
  }
5000 5246
  else
5001 5247
    dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );
......
5822 6068
    return QPixmap( myDefaultPath );
5823 6069
  }
5824 6070
}
6071

  
6072
QgisApp::Tools::~Tools()
6073
{
6074
  delete mZoomIn;
6075
  delete mZoomOut;
6076
  delete mPan;
6077
  delete mIdentify;
6078
  delete mMeasureDist;
6079
  delete mMeasureArea;
6080
  delete mCapturePoint;
6081
  delete mCaptureLine;
6082
  delete mCapturePolygon;
6083
  delete mMoveFeature;
6084
  delete mSplitFeatures;
6085
  delete mSelect;
6086
  delete mVertexAdd;
6087
  delete mVertexMove;
6088
  delete mVertexDelete;
6089
  delete mAddRing;
6090
  delete mAddIsland;
6091
}
/usr/local/src/qgis/src/app/qgisappinterface.cpp (working copy)
29 29
#include "qgsmaplayerregistry.h"
30 30
#include "qgsmapcanvas.h"
31 31
#include "qgslegend.h"
32
#include "qgstabwidget.h"
32 33

  
33 34
QgisAppInterface::QgisAppInterface( QgisApp * _qgis )
34 35
    : qgis( _qgis )
......
141 142
  return qgis->mapCanvas();
142 143
}
143 144

  
145
QgsTabWidget * QgisAppInterface::tabWidget()
146
{
147
  return qgis->tabWidget();
148
}
149

  
144 150
QWidget * QgisAppInterface::mainWindow()
145 151
{
146 152
  return qgis;
......
174 180
  qgis->removeDockWidget( dockwidget );
175 181
}
176 182

  
183
void QgisAppInterface::addTabWidget( QWidget *page, const QString &label )
184
{
185
  qgis->addTabWidget( page, label );
186
}
187

  
188
void QgisAppInterface::addTabWidget( QWidget *page, const QIcon &icon, const QString &label )
189
{
190
  qgis->addTabWidget( page, icon, label );
191
}
192

  
193
void QgisAppInterface::insertTabWidget( int index, QWidget *page, const QString &label )
194
{
195
  qgis->insertTabWidget( index, page, label );
196
}
197

  
198
void QgisAppInterface::insertTabWidget( int index, QWidget *page, const QIcon &icon, const QString &label )
199
{
200
  qgis->insertTabWidget( index, page, icon, label );
201
}
202

  
203
void QgisAppInterface::removeTabWidget( int index )
204
{
205
  qgis->removeTabWidget( index );
206
}
207

  
177 208
void QgisAppInterface::refreshLegend( QgsMapLayer *l )
178 209
{
179 210
  if ( l && qgis && qgis->legend() )
/usr/local/src/qgis/src/gui/qgstabwidget.cpp (revision 0)
1
#include <QMouseEvent>
2
#include <QInputDialog>
3

  
4
#include "qgstabwidget.h"
5

  
6
QgsTabWidget::QgsTabWidget(QWidget *parent)
7
  : QTabWidget(parent)
8
{
9
  tabBar()->hide();
10
  connect(tabBar(), SIGNAL(tabMoved(int,int)), this, SLOT(tabMove(int, int)));
11
}
12

  
13
QgsTabWidget::~QgsTabWidget()
14
{
15
}
16

  
17
void QgsTabWidget::addTab(QWidget *widget, const QIcon &icon, const QString &label)
18
{
19
  QTabWidget::addTab(widget, icon, label);
20
  if (count() > 1) tabBar()->show();
21
}
22

  
23
void QgsTabWidget::addTab(QWidget *widget, const QString &label)
24
{
25
  QTabWidget::addTab(widget, label);
26
  if (count() > 1) tabBar()->show();
27
}
28

  
29
void QgsTabWidget::insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label)
30
{
31
  QTabWidget::insertTab(index, widget, icon, label);
32
  if (count() > 1) tabBar()->show();
33
}
34

  
35
void QgsTabWidget::insertTab(int index, QWidget *widget, const QString &label)
36
{
37
  QTabWidget::insertTab(index, widget, label);
38
  if (count() > 1) tabBar()->show();
39
}
40

  
41
void QgsTabWidget::removeTab(int index)
42
{
43
  if (count() != 1) {
44
    QTabWidget::removeTab(index);
45
    if (count() == 1) tabBar()->hide();
46
  }
47
}
48

  
49
void QgsTabWidget::mouseDoubleClickEvent(QMouseEvent *event)
50
{
51
  bool ok;
52
  QString myTabText = QInputDialog::getText(this, tr("Tab text"), tr("Enter new tab text:"),
53
                                            QLineEdit::Normal, tr("Canvas %1").arg(currentIndex() + 1), &ok);
54

  
55
  if (ok && !myTabText.isEmpty())
56
    setTabText(currentIndex(), myTabText);
57

  
58
  event->accept();
59
}
60

  
61
void QgsTabWidget::tabMove(int from, int to)
62
{
63
  emit tabMoved(from, to);
64
}
/usr/local/src/qgis/src/gui/CMakeLists.txt (working copy)
12 12
qgsfiledropedit.cpp
13 13
qgsgenericprojectionselector.cpp
14 14
qgsmapcanvas.cpp
15
qgstabwidget.cpp
15 16
qgsmapcanvasitem.cpp
16 17
qgsmapcanvasmap.cpp
17 18
qgsmapcanvassnapper.cpp
......
41 42
qgsmessageviewer.h
42 43
qgsprojectionselector.h
43 44
qgsquickprint.h
45
qgstabwidget.h
44 46
)
45 47

  
46 48
QT4_WRAP_CPP(QGIS_GUI_MOC_SRCS ${QGIS_GUI_MOC_HDRS})
......
121 123
qgsrubberband.h
122 124
qgsvertexmarker.h
123 125
qgsmaptip.h
126
qgstabwidget.h
124 127

  
125 128
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsdetaileditemwidgetbase.h
126 129
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsgenericprojectionselectorbase.h
/usr/local/src/qgis/src/gui/qgisinterface.h (working copy)
21 21

  
22 22
class QAction;
23 23
class QMenu;
24
class QIcon;
24 25
class QToolBar;
25 26
class QDockWidget;
26 27
class QMainWindow;
......
36 37
class QgsMapLayer;
37 38
class QgsMapCanvas;
38 39
class QgsRasterLayer;
40
class QgsTabWidget;
39 41
class QgsVectorLayer;
40 42

  
41 43
/** \ingroup gui
......
107 109
    /** Return a pointer to the map canvas */
108 110
    virtual QgsMapCanvas * mapCanvas() = 0;
109 111

  
112
    /** Return a pointer to the main tab widget that containing map canvas */
113
    virtual QgsTabWidget * tabWidget() = 0;
114

  
110 115
    /** Return a pointer to the main window (instance of QgisApp in case of QGIS) */
111 116
    virtual QWidget * mainWindow() = 0;
112 117

  
......
124 129
    /** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
125 130
    virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
126 131

  
132
    /** Add a tab to the tab widget with label */
133
    virtual void addTabWidget( QWidget *page, const QString &label ) = 0;
134

  
135
    /** Add a tab to the tab widget with icon and label */
136
    virtual void addTabWidget( QWidget *page, const QIcon &icon, const QString &label ) = 0;
137

  
138
    /** Insert a tab to the tab widget with label */
139
    virtual void insertTabWidget( int index, QWidget *page, const QString &label ) = 0;
140

  
141
    /** Insert a tab to the tab widget with icon and label */
142
    virtual void insertTabWidget( int index, QWidget *page, const QIcon &icon, const QString &label ) = 0;
143

  
144
    /** Remove specified tab from tab widget (doesn't delete it) */
145
    virtual void removeTabWidget( int index ) = 0;
146

  
127 147
    /** refresh the legend of a layer */
128 148
    virtual void refreshLegend( QgsMapLayer *l ) = 0;
129 149

  
/usr/local/src/qgis/src/gui/qgstabwidget.h (revision 0)
1
#ifndef QGSTABWIDGET_H
2
#define QGSTABWIDGET_H
3

  
4
#include <QTabWidget>
5
#include <QTabBar>
6

  
7
class QLineEdit;
8

  
9
class GUI_EXPORT QgsTabWidget : public QTabWidget
10
{
11
  Q_OBJECT
12

  
13
public:
14
  QgsTabWidget(QWidget *parent = 0);
15
  ~QgsTabWidget();
16

  
17
  void addTab(QWidget *widget, const QIcon &icon, const QString &label);
18
  void addTab(QWidget *widget, const QString &label);
19
  void insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label);
20
  void insertTab(int index, QWidget *widget, const QString &label);
21
  void removeTab(int index);
22

  
23
signals:
24
  void tabMoved(int from, int to);
25

  
26
public slots:
27
  void nextTab() { currentIndex() == count() - 1 ? setCurrentIndex(0) : setCurrentIndex(currentIndex() + 1); }
28
  void previousTab() { currentIndex() == 0 ? setCurrentIndex(count() - 1) : setCurrentIndex(currentIndex() - 1); }
29

  
30
private slots:
31
  void tabMove(int from, int to);
32

  
33
private:
34
  void mouseDoubleClickEvent(QMouseEvent *event);
35
};
36

  
37
#endif // QGSTABWIDGET_H