Feature request #1622

Implement capability to add tabs in the main window

Added by lynxID - over 15 years ago. Updated about 6 years ago.

Status:Open
Priority:Low
Assignee:lynxID -
Category:GUI
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:11682

Description

Index: python/gui/qgisinterface.sip ===================================================================
--- python/gui/qgisinterface.sip (revision 10465)
+++ python/gui/qgisinterface.sip (working copy)
@ -70,6 +70,9 @
/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas()=0;

+ /** Return a pointer to the main tab widget /
+ virtual QTabWidget * tabWidget()=0;
+
/
* Return a pointer to the main window (instance of QgisApp in case of QGIS) */
virtual QWidget * mainWindow()=0;

@ -90,6 +93,21 @
/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
virtual void removeDockWidget ( QDockWidget * dockwidget )=0;

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

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

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

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

/
* Remove specified tab widget from main window (doesn't delete it). Added in QGIS 1.1. /
+ virtual void removeTabWidget( int index )=0;
+
/
* refresh legend of a layer */
virtual void refreshLegend( QgsMapLayer * layer )=0;

Index: src/app/qgisappinterface.h ===================================================================
--- src/app/qgisappinterface.h (revision 10465)
+++ src/app/qgisappinterface.h (working copy)
@ -85,6 +85,9 @
/** Return a pointer to the map canvas used by qgisapp */
QgsMapCanvas * mapCanvas();

+ /** Return a pointer to the main tab widget that containing map canvas /
+ virtual QTabWidget * tabWidget();
+
/
* Gives access to main QgisApp object

Plugins don't need to know about [[QgisApp]], as we pass it as QWidget,
@ -105,6 +108,21 @
/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
void removeDockWidget( QDockWidget * dockwidget );

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

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

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

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

/
* Remove specified tab widget from main window (doesn't delete it). Added in QGIS 1.1. */
+ void removeTabWidget( int index );
+
virtual void refreshLegend( QgsMapLayer *l ); ===================================================================
--- src/app/qgisapp.h (revision 10465)
++ src/app/qgisapp.h (working copy)
@ -59,6 +59,8 @
#include <QToolBar>
#include <QAbstractSocket>
#include <QPointer>
#include <QTabWidget>
+#include <QTabBar>

#include "qgsconfig.h" 
#include "qgspoint.h"
@ -137,8 +139,11 @
//!Overloaded version of the private function with same name that takes the imagename as a parameter
void saveMapAsImage( QString, QPixmap * );
/** Get the mapcanvas object from the app */
- [[QgsMapCanvas]] * mapCanvas() { return mMapCanvas; };
+ [[QgsMapCanvas]] * mapCanvas() { return mMapCanvas; }
+ /** Get the tabwidget object from the app /
+ QTabWidget * tabWidget() { return mTabWidget; }
+
QgsComposer
printComposer() {return mComposer;}
  • After adding the dock widget to the ui (by delegating to the QMainWindow
  • parent class, it will also add it to the View menu list of docks.*/
    void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget );

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

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

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

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

    /
    * Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. /
    + void removeTabWidget( int index );
    +
    /
    * Add a toolbar to the main window. Overloaded from QMainWindow.
  • After adding the toolbar to the ui (by delegating to the QMainWindow
  • parent class, it will also add it to the View menu list of toolbars.*/
    @ -814,6 +835,20 @
    QgsMapTool* mAddIsland;
    } mMapTools;
//! Set theme (icons)
@ -180,6 +185,22 @

// class QgsTabWidget : public QTabWidget
// {
// public:
// QgsTabWidget(QWidget *parent) {
// QgsTabWidget::QTabWidget();
// tabBar()->hide();
// }
// void addTab(QWidget *widget, const QIcon &icon, const QString &label) { QTabWidget::addTab(widget, icon, label); if (count() > 1) tabBar()->show(); }
// void addTab(QWidget *widget, const QString &label) { QTabWidget::addTab(widget, label); if (count() > 1) tabBar()->show(); }
// void insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label) { QTabWidget::insertTab(index, widget, icon, label); if (count() > 1) tabBar()->show(); }
// void insertTab(int index, QWidget *widget, const QString &label) { QTabWidget::insertTab(index, widget, label); if (count() > 1) tabBar()->show(); }
// void removeTab(int index) { if (count() != 1) { QTabWidget::removeTab(index); if (count() 1) tabBar()->hide(); } }
// };

QgsMapTool *mNonEditMapTool;

//! Widget that will live on the statusbar to display "scale 1:" 
@ -846,6 +881,9 @
QMenu *toolPopupCapture;
//! Map canvas
[[QgsMapCanvas]] *mMapCanvas;
+ //! Tab widget
// [[QgsTabWidget]] *mTabWidget;
QTabWidget *mTabWidget;
//! Table of contents (legend) for the map
[[QgsLegend]] *mMapLegend;
//! Cursor for the overview map
Index: src/app/qgisapp.cpp
=================================================================
--- src/app/qgisapp.cpp (revision 10465)
++ src/app/qgisapp.cpp (working copy)
@ -1548,8 +1548,8 @
// Connect warning dialog from project reading
connect( [[QgsProject]]::instance(), SIGNAL ),
this, SLOT ) );
}

-}
void QgisApp::createCanvas() {
// "theMapCanvas" used to find this canonical instance later
@ -1557,7 +1557,12 @
mMapCanvas->setWhatsThis( tr( "Map canvas. This is where raster and vector "
"layers are displayed when added to the map" ) );

- setCentralWidget( mMapCanvas );
+ mTabWidget = new QTabWidget(this);
+ mTabWidget->setTabPosition(QTabWidget::East);
+ mTabWidget->addTab(mMapCanvas, tr("2D view"));

setCentralWidget( mTabWidget );
+
// set the focus to the map canvas
mMapCanvas->setFocus();

@ -1653,6 +1658,31 @
mMapCanvas->refresh();
}

void QgisApp::addTabWidget( QWidget *page, const QString &label )
{
+ mTabWidget->addTab( page, label );
}

void QgisApp::addTabWidget( QWidget *page, const QIcon &icon, const QString &label )
{
+ mTabWidget->addTab( page, icon, label );
}

void QgisApp::insertTabWidget( int index, QWidget *page, const QString &label )
{
+ mTabWidget->insertTab( index, page, label );
}

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

void QgisApp::removeTabWidget( int index )
{
+ mTabWidget->removeTab( index );
}

QToolBar *QgisApp::addToolBar( QString name ) {
QToolBar *toolBar = QMainWindow::addToolBar( name );
Index: src/app/qgisappinterface.cpp ===================================================================
--- src/app/qgisappinterface.cpp (revision 10465)
+++ src/app/qgisappinterface.cpp (working copy)
@ -136,6 +136,11 @
return qgis->mapCanvas();
}

QTabWidget * QgisAppInterface::tabWidget()
{
+ return qgis->tabWidget();
}

QWidget * QgisAppInterface::mainWindow() {
return qgis;
@ -169,6 +174,31 @
qgis->removeDockWidget( dockwidget );
}

void QgisAppInterface::addTabWidget( QWidget *page, const QString &label )
{
+ qgis->addTabWidget( page, label );
}

void QgisAppInterface::addTabWidget( QWidget *page, const QIcon &icon, const QString &label )
{
+ qgis->addTabWidget( page, icon, label );
}

void QgisAppInterface::insertTabWidget( int index, QWidget *page, const QString &label )
{
+ qgis->insertTabWidget( index, page, label );
}

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

void QgisAppInterface::removeTabWidget( int index )
{
+ qgis->removeTabWidget( index );
}

void QgisAppInterface::refreshLegend( QgsMapLayer *l ) {
if ( l && qgis && qgis->legend() ) ===================================================================
--- src/gui/qgisinterface.h (revision 10465)
+++ src/gui/qgisinterface.h (working copy)
@ -25,6 +25,8 @
class QDockWidget;
class QMainWindow;
class QWidget;
+class QTabWidget;
+class QIcon;
#include <QObject>
#include <QPair>

@ -104,6 +106,9 @
/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas() = 0;

+ /** Return a pointer to the main tab widget /
+ virtual QTabWidget * tabWidget() = 0;
+
/
* Return a pointer to the main window (instance of QgisApp in case of QGIS) */
virtual QWidget * mainWindow() = 0;

@ -121,6 +126,21 @
/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;

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

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

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

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

/
* Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. /
+ virtual void removeTabWidget( int index ) = 0;
+
/
* refresh the legend of a layer */
virtual void refreshLegend( QgsMapLayer *l ) = 0;

addTabWidget.patch Magnifier (12.2 KB) lynxID -, 2009-04-04 01:05 PM

addTabWidget2.patch Magnifier (11.8 KB) lynxID -, 2009-04-23 04:11 PM

addTabWidget2.2.patch Magnifier - with python (14.7 KB) lynxID -, 2009-04-24 02:53 AM

qgis_tabs.patch Magnifier (50 KB) lynxID -, 2009-05-02 10:35 AM

tabs_05-11-09.patch Magnifier - Patch to add tabs on the Qgis canvas (136 KB) epifanio -, 2009-11-07 12:23 AM

History

#1 Updated by lynxID - over 15 years ago

The patch implement an ability to add tabs.

#2 Updated by Martin Dobias over 15 years ago

I would suggest you to modify the patch. With this patch, users will get a tabbed view with tab "2d view" containing map canvas. However in common use case when not using ossim planet plugin, the user has lost several pixels of canvas on every border, moreover it can create some confusion "if this is a 2d view, where are the other views?".

The best option would be to create the tab view only on request on a new tab and to remove the tab view once there's only one remaining tab.

#3 Updated by epifanio - almost 15 years ago

this a link to download the add_tabs.patch and relative icons needed by the patch :

http://[email protected]/trunk/icons
http://[email protected]/trunk/tabs_patches

copy them in : qgis_trunk/images/themes/default

#4 Updated by Giovanni Manghi almost 13 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#5 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from Version 1.7.4 to Version 2.0.0

#6 Updated by Pirmin Kalberer about 12 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

#7 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No
  • Pull Request or Patch supplied set to No

Also available in: Atom PDF