allow to add a QToolBar to QGisInterface (will allow subclassing)

This commit is contained in:
Denis Rouzaud 2014-04-10 15:28:52 +02:00
parent d2b1c82997
commit 26e94fec6f
6 changed files with 32 additions and 0 deletions

View File

@ -162,6 +162,10 @@ class QgisInterface : QObject
//! Add toolbar with specified name
virtual QToolBar *addToolBar( QString name ) = 0 /Factory/;
//! Add a toolbar
//! @note added in 2.3
virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas() = 0;

View File

@ -2135,6 +2135,13 @@ QToolBar *QgisApp::addToolBar( QString name )
return toolBar;
}
void QgisApp::addToolBar( QToolBar* toolBar , Qt::ToolBarArea area )
{
QMainWindow::addToolBar( area, toolBar );
// add to the Toolbar submenu
mToolbarMenu->addAction( toolBar->toggleViewAction() );
}
QgsLegend *QgisApp::legend()
{
Q_ASSERT( mMapLegend );

View File

@ -211,6 +211,14 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* parent class, it will also add it to the View menu list of toolbars.*/
QToolBar *addToolBar( QString name );
/** 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.
* @note added in 2.3
*/
void addToolBar( QToolBar* toolBar, Qt::ToolBarArea area = Qt::TopToolBarArea );
/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
void addWindow( QAction *action );

View File

@ -285,6 +285,11 @@ QToolBar* QgisAppInterface::addToolBar( QString name )
return qgis->addToolBar( name );
}
void QgisAppInterface::addToolBar( QToolBar *toolbar, Qt::ToolBarArea area )
{
return qgis->addToolBar( toolbar, area );
}
void QgisAppInterface::openURL( QString url, bool useQgisDocDirectory )
{
qgis->openURL( url, useQgisDocDirectory );

View File

@ -146,6 +146,10 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
//! Add toolbar with specified name
QToolBar* addToolBar( QString name );
//! Add a toolbar
//! @note added in 2.3
void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea );
/** Open a url in the users browser. By default the QGIS doc directory is used
* as the base for the URL. To open a URL that is not relative to the installed
* QGIS documentation, set useQgisDocDirectory to false.

View File

@ -205,6 +205,10 @@ class GUI_EXPORT QgisInterface : public QObject
//! Add toolbar with specified name
virtual QToolBar *addToolBar( QString name ) = 0;
//! Add a toolbar
//! @note added in 2.3
virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas() = 0;