addTabWidget2.2.patch

with python - lynxID -, 2009-04-24 02:53 AM

Download (14.7 KB)

View differences:

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

  
10
class QgsTabWidget: QTabWidget
11
{
12
%TypeHeaderCode
13
#include <qgstabwidget.h>
14
%End
15

  
16
public:
17
  QgsTabWidget(QWidget *parent); 
18
  void addTab(QWidget *widget, const QIcon &icon, const QString &label);
19
  void addTab(QWidget *widget, const QString &label);
20
  void insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label);
21
  void insertTab(int index, QWidget *widget, const QString &label);
22
  void removeTab(int index);
23
};
24

  
/usr/local/src/qgis_ossim_pan/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_ossim_pan/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_ossim_pan/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_ossim_pan/src/app/qgisapp.h (working copy)
54 54
class QgsRasterLayer;
55 55
class QgsRectangle;
56 56
class QgsVectorLayer;
57
class QgsTabWidget;
57 58

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

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

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

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

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

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

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

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

  
200
    /** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
201
    void removeTabWidget( int index );
202

  
183 203
    /** Add a toolbar to the main window. Overloaded from QMainWindow.
184 204
     * After adding the toolbar to the ui (by delegating to the QMainWindow
185 205
     * parent class, it will also add it to the View menu list of toolbars.*/
......
850 870
    QMenu *toolPopupCapture;
851 871
    //! Map canvas
852 872
    QgsMapCanvas *mMapCanvas;
873
    //! Tab widget
874
    QgsTabWidget *mTabWidget;
853 875
    //! Table of contents (legend) for the map
854 876
    QgsLegend *mMapLegend;
855 877
    //! Cursor for the overview map
/usr/local/src/qgis_ossim_pan/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"
......
1563 1564
  mMapCanvas->setWhatsThis( tr( "Map canvas. This is where raster and vector "
1564 1565
                                "layers are displayed when added to the map" ) );
1565 1566

  
1566
  setCentralWidget( mMapCanvas );
1567
  mTabWidget = new QgsTabWidget(this);
1568
  mTabWidget->setTabPosition(QTabWidget::East);
1569
  mTabWidget->addTab(mMapCanvas, tr("2D view"));  
1570

  
1571
  setCentralWidget( mTabWidget );
1572

  
1567 1573
  // set the focus to the map canvas
1568 1574
  mMapCanvas->setFocus();
1569 1575

  
......
1659 1665
  mMapCanvas->refresh();
1660 1666
}
1661 1667

  
1668
void QgisApp::addTabWidget( QWidget *page, const QString &label )
1669
{
1670
  mTabWidget->addTab( page, label );
1671
}
1672

  
1673
void QgisApp::addTabWidget( QWidget *page, const QIcon &icon, const QString &label )
1674
{
1675
  mTabWidget->addTab( page, icon, label );
1676
}
1677

  
1678
void QgisApp::insertTabWidget( int index, QWidget *page, const QString &label )
1679
{
1680
  mTabWidget->insertTab( index, page, label );
1681
}
1682

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

  
1688
void QgisApp::removeTabWidget( int index )
1689
{
1690
  mTabWidget->removeTab( index );
1691
}
1692

  
1662 1693
QToolBar *QgisApp::addToolBar( QString name )
1663 1694
{
1664 1695
  QToolBar *toolBar = QMainWindow::addToolBar( name );
/usr/local/src/qgis_ossim_pan/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_ossim_pan/src/gui/qgstabwidget.cpp (revision 0)
1
#include "qgstabwidget.h"
2

  
3
void QgsTabWidget::addTab(QWidget *widget, const QIcon &icon, const QString &label)
4
{
5
  QTabWidget::addTab(widget, icon, label);
6
  if (count() > 1) tabBar()->show();
7
}
8

  
9
void QgsTabWidget::addTab(QWidget *widget, const QString &label)
10
{
11
  QTabWidget::addTab(widget, label);
12
  if (count() > 1) tabBar()->show();
13
}
14

  
15
void QgsTabWidget::insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label)
16
{
17
  QTabWidget::insertTab(index, widget, icon, label);
18
  if (count() > 1) tabBar()->show();
19
}
20

  
21
void QgsTabWidget::insertTab(int index, QWidget *widget, const QString &label)
22
{
23
  QTabWidget::insertTab(index, widget, label);
24
  if (count() > 1) tabBar()->show();
25
}
26

  
27
void QgsTabWidget::removeTab(int index)
28
{
29
  if (count() != 1) {
30
    QTabWidget::removeTab(index);
31
    if (count() == 1) tabBar()->hide();
32
  }
33
}
/usr/local/src/qgis_ossim_pan/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
......
121 122
qgsrubberband.h
122 123
qgsvertexmarker.h
123 124
qgsmaptip.h
125
qgstabwidget.h
124 126

  
125 127
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsdetaileditemwidgetbase.h
126 128
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsgenericprojectionselectorbase.h
/usr/local/src/qgis_ossim_pan/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 widget to the main window */
133
    virtual void addTabWidget( QWidget *page, const QString &label ) = 0;
134

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

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

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

  
144
    /** Remove specified tab widget from main window (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_ossim_pan/src/gui/qgstabwidget.h (revision 0)
1
#ifndef QGSTABWIDGET_H
2
#define QGSTABWIDGET_H
3

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

  
7
class QgsTabWidget : public QTabWidget
8
{
9
public:
10
  QgsTabWidget(QWidget *parent) {
11
    QgsTabWidget::QTabWidget();
12
    tabBar()->hide();
13
  }
14
  void addTab(QWidget *widget, const QIcon &icon, const QString &label);
15
  void addTab(QWidget *widget, const QString &label);
16
  void insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label);
17
  void insertTab(int index, QWidget *widget, const QString &label);
18
  void removeTab(int index);
19
};
20

  
21
#endif // QGSTABWIDGET_H