[QGIS-trac] [Quantum GIS] #1622: Implement capability to add tabs
in the main window
Quantum GIS
qgis at qgis.org
Sat Apr 4 16:03:48 EDT 2009
#1622: Implement capability to add tabs in the main window
-----------------------------------------------+----------------------------
Reporter: lynxID | Owner: lynxID
Type: patch | Status: new
Priority: minor: annoyance or enhancement | Milestone: Version 1.1.0
Component: Build/Install | Version: HEAD
Keywords: tabs | Platform_version:
Platform: Fedora | Must_fix: No
Status_info: 0 |
-----------------------------------------------+----------------------------
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 );
/** Add window to Window menu. The action title is the window title
Index: src/app/qgisapp.h
===================================================================
--- 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;}
//! Set theme (icons)
@@ -180,6 +185,22 @@
* 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;
+// 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( oldProjectVersionWarning(
QString ) ),
this, SLOT( oldProjectVersionWarning( QString ) ) );
+}
-}
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;
--
Ticket URL: <https://trac.osgeo.org/qgis/ticket/1622>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats
More information about the QGIS-trac
mailing list