-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[addlayerbutton] Initial implementation
- Loading branch information
Showing
8 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <QMessageBox> | ||
#include <QListWidgetItem> | ||
#include <QMdiArea> | ||
#include <QMdiSubWindow> | ||
|
||
#include "qgsdatasourcemanagerdialog.h" | ||
#include "ui_qgsdatasourcemanagerdialog.h" | ||
#include "qgsbrowserdockwidget.h" | ||
#include "qgssettings.h" | ||
#include "qgsproviderregistry.h" | ||
|
||
QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent ) : | ||
QDialog( parent ), | ||
ui( new Ui::QgsDataSourceManagerDialog ) | ||
{ | ||
ui->setupUi( this ); | ||
|
||
// More setup | ||
int size = QgsSettings().value( QStringLiteral( "/IconSize" ), 24 ).toInt(); | ||
// buffer size to match displayed icon size in toolbars, and expected geometry restore | ||
// newWidth (above) may need adjusted if you adjust iconBuffer here | ||
int iconBuffer = 4; | ||
ui->mList->setIconSize( QSize( size + iconBuffer, size + iconBuffer ) ); | ||
ui->mList->setFrameStyle( QFrame::NoFrame ); | ||
ui->mListFrame->layout()->setContentsMargins( 0, 3, 3, 3 ); | ||
|
||
// Bind list index to the stacked dialogs | ||
connect( ui->mList, SIGNAL( currentRowChanged( int ) ), this, SLOT( setCurrentPage( int ) ) ); | ||
|
||
// Add the browser widget to the first stacked widget page | ||
mBrowserWidget = new QgsBrowserDockWidget( QStringLiteral( "Browser" ), this ); | ||
mBrowserWidget->setFeatures( QDockWidget::NoDockWidgetFeatures ); | ||
ui->mStackedWidget->addWidget( mBrowserWidget ); | ||
|
||
// Add data provider dialogs | ||
|
||
// WMS | ||
QDialog *wmss = dynamic_cast<QDialog *>( QgsProviderRegistry::instance()->createSelectionWidget( QStringLiteral( "wms" ), this ) ); | ||
if ( !wmss ) | ||
{ | ||
QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) ); | ||
} | ||
else | ||
{ | ||
connect( wmss, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ), | ||
qApp, SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) ); | ||
//wmss->exec(); | ||
wmss->setWindowFlags( Qt::Widget ); | ||
QMdiArea *wmsMdi = new QMdiArea( this ); | ||
QMdiSubWindow *wmsSub; | ||
wmsMdi->setViewMode( QMdiArea::TabbedView ); | ||
wmsSub = wmsMdi->addSubWindow( wmss ); | ||
wmsSub->show(); | ||
ui->mStackedWidget->addWidget( wmsMdi ); | ||
mDialogs.append( wmss ); // TODO: rm | ||
QListWidgetItem *wmsItem = new QListWidgetItem( tr( "WMS" ), ui->mList ); | ||
wmsItem->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddWmsLayer.svg" ) ) ); | ||
} | ||
|
||
} | ||
|
||
QgsDataSourceManagerDialog::~QgsDataSourceManagerDialog() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void QgsDataSourceManagerDialog::setCurrentPage( int index ) | ||
{ | ||
ui->mStackedWidget->setCurrentIndex( index ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef QGSDATASOURCEMANAGERDIALOG_H | ||
#define QGSDATASOURCEMANAGERDIALOG_H | ||
|
||
#include <QList> | ||
#include <QDialog> | ||
class QgsBrowserDockWidget; | ||
|
||
|
||
namespace Ui | ||
{ | ||
class QgsDataSourceManagerDialog; | ||
} | ||
|
||
class QgsDataSourceManagerDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QgsDataSourceManagerDialog( QWidget *parent = 0 ); | ||
~QgsDataSourceManagerDialog(); | ||
|
||
public slots: | ||
void setCurrentPage( int index ); | ||
|
||
private: | ||
Ui::QgsDataSourceManagerDialog *ui; | ||
QgsBrowserDockWidget *mBrowserWidget = nullptr; | ||
QList<QDialog *> mDialogs; | ||
}; | ||
|
||
#endif // QGSDATASOURCEMANAGERDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>QgsDataSourceManagerDialog</class> | ||
<widget class="QDialog" name="QgsDataSourceManagerDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>900</width> | ||
<height>600</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Data Source Manager</string> | ||
</property> | ||
<layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
<item> | ||
<widget class="QSplitter" name="mSplitter"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<widget class="QFrame" name="mListFrame"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="frameShape"> | ||
<enum>QFrame::StyledPanel</enum> | ||
</property> | ||
<property name="frameShadow"> | ||
<enum>QFrame::Raised</enum> | ||
</property> | ||
<layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
<item> | ||
<widget class="QListWidget" name="mList"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>58</width> | ||
<height>0</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>160</width> | ||
<height>16777215</height> | ||
</size> | ||
</property> | ||
<item> | ||
<property name="text"> | ||
<string>Browser</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="../../images/images.qrc"> | ||
<normaloff>:/images/themes/default/mActionFileOpen.svg</normaloff>:/images/themes/default/mActionFileOpen.svg</iconset> | ||
</property> | ||
</item> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<widget class="QFrame" name="mDialogsFrame"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="frameShape"> | ||
<enum>QFrame::StyledPanel</enum> | ||
</property> | ||
<property name="frameShadow"> | ||
<enum>QFrame::Raised</enum> | ||
</property> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QStackedWidget" name="mStackedWidget"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="currentIndex"> | ||
<number>-1</number> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources> | ||
<include location="../../images/images.qrc"/> | ||
</resources> | ||
<connections/> | ||
</ui> |