mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Add missing files
This commit is contained in:
parent
0553f7b33b
commit
659d91649c
166
python/gui/qgspanelwidget.sip
Normal file
166
python/gui/qgspanelwidget.sip
Normal file
@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @brief Base class for any widget that can be shown as a inline panel
|
||||
*/
|
||||
class QgsPanelWidget : public QWidget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include "qgspanelwidget.h"
|
||||
%End
|
||||
public:
|
||||
/**
|
||||
* @brief Base class for any widget that can be shown as a inline panel
|
||||
* @param parent Parent widget.
|
||||
*/
|
||||
QgsPanelWidget( QWidget *parent = 0 );
|
||||
|
||||
/**
|
||||
* Set the title of the panel when shown in the interface.
|
||||
* @param panelTitle The panel title.
|
||||
*/
|
||||
void setPanelTitle( QString panelTitle );
|
||||
|
||||
/**
|
||||
* The title of the panel.
|
||||
* @return The title pf the panel.
|
||||
*/
|
||||
QString panelTitle();
|
||||
|
||||
/**
|
||||
* Connect the given sub panel widgets showPanel signals to this current panels
|
||||
* main showPanel event to bubble up to the user.
|
||||
*
|
||||
* Use this method if you have children widgets that need to show a panel to the user.
|
||||
* @param panels A list of panel widgets to connect.
|
||||
*/
|
||||
void connectChildPanels( QList<QgsPanelWidget*> panels );
|
||||
|
||||
/**
|
||||
* Connect the given sub panel widgets showPanel signals to this current panels
|
||||
* main showPanel event to bubble up to the user.
|
||||
*
|
||||
* Use this method if you have children widgets that need to show a panel to the user.
|
||||
* @param panel The panel to connect.
|
||||
*/
|
||||
void connectChildPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Set the widget in dock mode which tells the widget to emit panel
|
||||
* widgets and not open dialogs
|
||||
* @param dockMode True to enable dock mode.
|
||||
*/
|
||||
virtual void setDockMode( bool dockMode );
|
||||
signals:
|
||||
|
||||
/**
|
||||
* Emiited when the panel is accpeted by the user.
|
||||
* @param panel The panel widget that was accepted.
|
||||
* @note This argument is normally raised with emit panelAccpeted(this)
|
||||
* so that callers can retrive the widget easier in calling code.
|
||||
*/
|
||||
void panelAccepted( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Emit when you require a panel to be show in the interface.
|
||||
* @param panel The panel widget to show.
|
||||
* @note If you are connected to this signal you should also connect
|
||||
* given panels showPanel signal as they can be nested.
|
||||
*/
|
||||
void showPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Emiited when the widget state changes.
|
||||
* Connect to this to pull any changes off the widget when needed.
|
||||
* As panels are non blocking "dialogs" you should listen to this signal
|
||||
* to give the user feedback when something changes.
|
||||
*/
|
||||
void widgetChanged();
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
* Accept the panel. Causes panelAccepted to be emiited.
|
||||
* Widgets are normally removed form the interface using the panel manager or the caller.
|
||||
*/
|
||||
void acceptPanel();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief Overriden key press event to handle the esc event on the widget.
|
||||
* @param event The key event
|
||||
*/
|
||||
void keyPressEvent( QKeyEvent* event );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A non model panel page that can get shown to the user. Page will contain a close button and trigger the
|
||||
* internal widgets acceptPanel() on close.
|
||||
*/
|
||||
class QgsPanelWidgetPage : public QgsPanelWidget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include "qgspanelwidget.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
/**
|
||||
* A non model panel page that can get shown to the user.
|
||||
* @param widget The internal widget to show in the page.
|
||||
* @param parent THe parent widget.
|
||||
*/
|
||||
QgsPanelWidgetPage( QgsPanelWidget* widget, QWidget* parent = nullptr );
|
||||
|
||||
~QgsPanelWidgetPage();
|
||||
|
||||
void setTitle( QString title );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A stack widget to manage panels in the interface. Handles the open and close events
|
||||
* for added panels.
|
||||
* Any widgets that want to have a non blocking panel based interface should use this
|
||||
* class to manage the panels.
|
||||
*/
|
||||
class QgsPanelWidgetStackWidget : public QStackedWidget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include "qgspanelwidget.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
/**
|
||||
* A stack widget to manage panels in the interface. Handles the open and close events
|
||||
* for added panels.
|
||||
* @param parent
|
||||
*/
|
||||
QgsPanelWidgetStackWidget( QWidget* parent = nullptr );
|
||||
|
||||
void connectPanels( QList<QgsPanelWidget*> panels );
|
||||
|
||||
void connectPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Adds the main widget to the stack and selects it for the user
|
||||
* The main widget can not be closed and only the showPanel signal is attached
|
||||
* to handle children widget opening panels.
|
||||
* @param panel The panel to set as the first widget in the stack.
|
||||
*/
|
||||
void addMainPanel( QgsPanelWidget* panel );
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
|
||||
* nested panels. Auto switches the the given panel for the user.
|
||||
* @param panel The panel to show.
|
||||
*/
|
||||
void showPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Closes the panel in the widget. Will also delete the widget.
|
||||
* This slot is normally auto connected to panelAccepted when a panel is shown.
|
||||
* @param panel The panel to close.
|
||||
*/
|
||||
void closePanel( QgsPanelWidget* panel );
|
||||
};
|
134
src/gui/qgspanelwidget.cpp
Normal file
134
src/gui/qgspanelwidget.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/***************************************************************************
|
||||
qgspanelwidget.cpp
|
||||
---------------------
|
||||
begin : June 2016
|
||||
copyright : (C) 2016 by Nathan Woodrow
|
||||
email :
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "qgspanelwidget.h"
|
||||
#include "qgslogger.h"
|
||||
|
||||
QgsPanelWidget::QgsPanelWidget( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
}
|
||||
|
||||
void QgsPanelWidget::connectChildPanels( QList<QgsPanelWidget *> panels )
|
||||
{
|
||||
Q_FOREACH ( QgsPanelWidget* widget, panels )
|
||||
{
|
||||
connectChildPanel( widget );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsPanelWidget::connectChildPanel( QgsPanelWidget *panel )
|
||||
{
|
||||
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SIGNAL( showPanel( QgsPanelWidget* ) ) );
|
||||
connect( panel, SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) );
|
||||
}
|
||||
|
||||
void QgsPanelWidget::setDockMode(bool dockMode)
|
||||
{
|
||||
mDockMode = true;
|
||||
}
|
||||
|
||||
void QgsPanelWidget::acceptPanel()
|
||||
{
|
||||
emit panelAccepted( this );
|
||||
}
|
||||
|
||||
void QgsPanelWidget::keyPressEvent( QKeyEvent *event )
|
||||
{
|
||||
if ( event->key() == Qt::Key_Escape )
|
||||
{
|
||||
acceptPanel();
|
||||
}
|
||||
}
|
||||
|
||||
QgsPanelWidgetPage::QgsPanelWidgetPage( QgsPanelWidget *widget, QWidget *parent )
|
||||
: QgsPanelWidget( parent )
|
||||
, mWidget( widget )
|
||||
{
|
||||
setupUi( this );
|
||||
mWidgetLayout->addWidget( widget );
|
||||
mWidgetLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||
mTitleText->setText( widget->panelTitle() );
|
||||
|
||||
connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptPanel() ) );
|
||||
connect( widget, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( acceptPanel() ) );
|
||||
connect( widget, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SIGNAL( showPanel( QgsPanelWidget* ) ) );
|
||||
}
|
||||
|
||||
QgsPanelWidgetPage::~QgsPanelWidgetPage()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsPanelWidgetPage::setTitle( QString title )
|
||||
{
|
||||
mTitleText->setText( title );
|
||||
}
|
||||
|
||||
QgsPanelWidgetStackWidget::QgsPanelWidgetStackWidget( QWidget *parent )
|
||||
: QStackedWidget( parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QgsPanelWidgetStackWidget::connectPanels( QList<QgsPanelWidget *> panels )
|
||||
{
|
||||
Q_FOREACH ( QgsPanelWidget* widget, panels )
|
||||
{
|
||||
connectPanel( widget );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsPanelWidgetStackWidget::connectPanel( QgsPanelWidget *panel )
|
||||
{
|
||||
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) );
|
||||
}
|
||||
|
||||
void QgsPanelWidgetStackWidget::addMainPanel( QgsPanelWidget *panel )
|
||||
{
|
||||
// TODO Don't allow adding another main widget or else that would be strange for the user.
|
||||
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) );
|
||||
this->insertWidget( 0, panel );
|
||||
this->setCurrentIndex( 0 );
|
||||
}
|
||||
|
||||
void QgsPanelWidgetStackWidget::showPanel( QgsPanelWidget *panel )
|
||||
{
|
||||
mTitles.push( panel->panelTitle() );
|
||||
QString breadcrumb;
|
||||
Q_FOREACH ( QString title, mTitles )
|
||||
{
|
||||
breadcrumb += QString( " %1 >" ).arg( title );
|
||||
}
|
||||
breadcrumb.chop( 1 );
|
||||
|
||||
QgsPanelWidgetPage* page = new QgsPanelWidgetPage( panel, this );
|
||||
page->setTitle( breadcrumb );
|
||||
|
||||
connect( page, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( closePanel( QgsPanelWidget* ) ) );
|
||||
connect( page, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) );
|
||||
|
||||
int index = this->addWidget( page );
|
||||
this->setCurrentIndex( index );
|
||||
}
|
||||
|
||||
void QgsPanelWidgetStackWidget::closePanel( QgsPanelWidget *panel )
|
||||
{
|
||||
this->setCurrentIndex( this->currentIndex() - 1 );
|
||||
this->removeWidget( panel );
|
||||
mTitles.pop();
|
||||
panel->deleteLater();
|
||||
}
|
211
src/gui/qgspanelwidget.h
Normal file
211
src/gui/qgspanelwidget.h
Normal file
@ -0,0 +1,211 @@
|
||||
/***************************************************************************
|
||||
qgspanelwidget.h
|
||||
---------------------
|
||||
begin : June 2016
|
||||
copyright : (C) 2016 by Nathan Woodrow
|
||||
email :
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSPANELWIDGET_H
|
||||
#define QGSPANELWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QStackedWidget>
|
||||
#include <QStack>
|
||||
|
||||
#include "ui_qgsrenderercontainerbase.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Base class for any widget that can be shown as a inline panel
|
||||
*/
|
||||
class GUI_EXPORT QgsPanelWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Base class for any widget that can be shown as a inline panel
|
||||
* @param parent Parent widget.
|
||||
*/
|
||||
QgsPanelWidget( QWidget *parent = 0 );
|
||||
|
||||
/**
|
||||
* Set the title of the panel when shown in the interface.
|
||||
* @param panelTitle The panel title.
|
||||
*/
|
||||
void setPanelTitle( QString panelTitle ) { mPanelTitle = panelTitle; }
|
||||
|
||||
/**
|
||||
* The title of the panel.
|
||||
* @return The title pf the panel.
|
||||
*/
|
||||
QString panelTitle() { return mPanelTitle; }
|
||||
|
||||
/**
|
||||
* Connect the given sub panel widgets showPanel signals to this current panels
|
||||
* main showPanel event to bubble up to the user.
|
||||
*
|
||||
* Use this method if you have children widgets that need to show a panel to the user.
|
||||
* @param panels A list of panel widgets to connect.
|
||||
*/
|
||||
void connectChildPanels( QList<QgsPanelWidget*> panels );
|
||||
|
||||
/**
|
||||
* Connect the given sub panel widgets showPanel signals to this current panels
|
||||
* main showPanel event to bubble up to the user.
|
||||
*
|
||||
* Use this method if you have children widgets that need to show a panel to the user.
|
||||
* @param panel The panel to connect.
|
||||
*/
|
||||
void connectChildPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Set the widget in dock mode which tells the widget to emit panel
|
||||
* widgets and not open dialogs
|
||||
* @param dockMode True to enable dock mode.
|
||||
*/
|
||||
virtual void setDockMode( bool dockMode );
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* Emiited when the panel is accpeted by the user.
|
||||
* @param panel The panel widget that was accepted.
|
||||
* @note This argument is normally raised with emit panelAccpeted(this)
|
||||
* so that callers can retrive the widget easier in calling code.
|
||||
*/
|
||||
void panelAccepted( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Emit when you require a panel to be show in the interface.
|
||||
* @param panel The panel widget to show.
|
||||
* @note If you are connected to this signal you should also connect
|
||||
* given panels showPanel signal as they can be nested.
|
||||
*/
|
||||
void showPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Emiited when the widget state changes.
|
||||
* Connect to this to pull any changes off the widget when needed.
|
||||
* As panels are non blocking "dialogs" you should listen to this signal
|
||||
* to give the user feedback when something changes.
|
||||
*/
|
||||
void widgetChanged();
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
* Accept the panel. Causes panelAccepted to be emiited.
|
||||
* Widgets are normally removed form the interface using the panel manager or the caller.
|
||||
*/
|
||||
void acceptPanel();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief Overriden key press event to handle the esc event on the widget.
|
||||
* @param event The key event
|
||||
*/
|
||||
void keyPressEvent( QKeyEvent* event );
|
||||
|
||||
private:
|
||||
QString mPanelTitle;
|
||||
bool mDockMode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A non model panel page that can get shown to the user. Page will contain a back button and trigger the
|
||||
* internal widgets acceptPanel() on close.
|
||||
*/
|
||||
class GUI_EXPORT QgsPanelWidgetPage : public QgsPanelWidget, private Ui::QgsRendererWidgetContainerBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* A non model panel page that can get shown to the user.
|
||||
* @param widget The internal widget to show in the page.
|
||||
* @param parent THe parent widget.
|
||||
*/
|
||||
QgsPanelWidgetPage( QgsPanelWidget* widget, QWidget* parent = nullptr );
|
||||
|
||||
~QgsPanelWidgetPage();
|
||||
|
||||
/**
|
||||
* Set the current display page for the panel.
|
||||
* @param title The title to show to the user.
|
||||
*/
|
||||
void setTitle( QString title );
|
||||
|
||||
private:
|
||||
QWidget* mWidget;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A stack widget to manage panels in the interface. Handles the open and close events
|
||||
* for added panels.
|
||||
* Any widgets that want to have a non blocking panel based interface should use this
|
||||
* class to manage the panels.
|
||||
*/
|
||||
class GUI_EXPORT QgsPanelWidgetStackWidget : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* A stack widget to manage panels in the interface. Handles the open and close events
|
||||
* for added panels.
|
||||
* @param parent
|
||||
*/
|
||||
QgsPanelWidgetStackWidget( QWidget* parent = nullptr );
|
||||
|
||||
/**
|
||||
* Shortcut method to connect panel widgets events to this stack widget.
|
||||
* @param panels The panels to connect.
|
||||
*/
|
||||
void connectPanels( QList<QgsPanelWidget*> panels );
|
||||
|
||||
/**
|
||||
* Shortcut method to connect panel widgets events to this stack widget.
|
||||
* @param panel The panel to connect.
|
||||
*/
|
||||
void connectPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Adds the main widget to the stack and selects it for the user
|
||||
* The main widget can not be closed and only the showPanel signal is attached
|
||||
* to handle children widget opening panels.
|
||||
* @param panel The panel to set as the first widget in the stack.
|
||||
*/
|
||||
void addMainPanel( QgsPanelWidget* panel );
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
|
||||
* nested panels. Auto switches the the given panel for the user.
|
||||
* @param panel The panel to show.
|
||||
*/
|
||||
void showPanel( QgsPanelWidget* panel );
|
||||
|
||||
/**
|
||||
* Closes the panel in the widget. Will also delete the widget.
|
||||
* This slot is normally auto connected to panelAccepted when a panel is shown.
|
||||
* @param panel The panel to close.
|
||||
*/
|
||||
void closePanel( QgsPanelWidget* panel );
|
||||
private:
|
||||
QStack<QString> mTitles;
|
||||
};
|
||||
|
||||
|
||||
#endif // QGSPANELWIDGET_H
|
Loading…
x
Reference in New Issue
Block a user