Skip to content
Permalink
Browse files

Move QgsBrowserDockWidget from app to gui

  • Loading branch information
elpaso committed Jun 2, 2017
1 parent 2d78ef8 commit f250b1911a9176bb65b3698bfbdb2cd9ef999e7b
@@ -16,7 +16,6 @@ SET(QGIS_APP_SRCS
qgsattributetypedialog.cpp
qgsattributetabledialog.cpp
qgsbookmarks.cpp
qgsbrowserdockwidget.cpp
qgsclipboard.cpp
qgscustomization.cpp
qgscustomprojectiondialog.cpp
@@ -204,7 +203,6 @@ SET (QGIS_APP_MOC_HDRS
qgsattributetypedialog.h
qgsattributetabledialog.h
qgsbookmarks.h
qgsbrowserdockwidget.h
qgsclipboard.h
qgscustomization.h
qgscustomprojectiondialog.h
@@ -885,11 +885,17 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mBrowserWidget->setObjectName( QStringLiteral( "Browser" ) );
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget );
mBrowserWidget->hide();
connect( this, &QgisApp::newProject, mBrowserWidget, &QgsBrowserDockWidget::updateProjectHome );
connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, &QgisApp::openFile );
connect( mBrowserWidget, &QgsBrowserDockWidget::handleDropUriList, this, &QgisApp::handleDropUriList );

mBrowserWidget2 = new QgsBrowserDockWidget( tr( "Browser Panel (2)" ), this );
mBrowserWidget2->setObjectName( QStringLiteral( "Browser2" ) );
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget2 );
mBrowserWidget2->hide();
connect( this, &QgisApp::newProject, mBrowserWidget2, &QgsBrowserDockWidget::updateProjectHome );
connect( mBrowserWidget2, &QgsBrowserDockWidget::openFile, this, &QgisApp::openFile );
connect( mBrowserWidget2, &QgsBrowserDockWidget::handleDropUriList, this, &QgisApp::handleDropUriList );

addDockWidget( Qt::LeftDockWidgetArea, mAdvancedDigitizingDockWidget );
mAdvancedDigitizingDockWidget->hide();
@@ -232,9 +232,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
bool addProject( const QString &projectFile );

/** Convenience function to open either a project or a layer file.
*/
void openFile( const QString &fileName );
//!Overloaded version of the private function with same name that takes the imagename as a parameter
void saveMapAsImage( const QString &, QPixmap * );

@@ -618,13 +615,16 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Unregister a previously registered custom drop handler.
void unregisterCustomDropHandler( QgsCustomDropHandler *handler );

public slots:
//! Process the list of URIs that have been dropped in QGIS
void handleDropUriList( const QgsMimeDataUtils::UriList &lst );

//! Returns the active map layer.
QgsMapLayer *activeLayer();

public slots:
//! Convenience function to open either a project or a layer file.
void openFile( const QString &fileName );
void layerTreeViewDoubleClicked( const QModelIndex &index );
//! Make sure the insertion point for new layers is up-to-date with the current item in layer tree view
void updateNewLayerInsertionPoint();
@@ -173,6 +173,7 @@ SET(QGIS_GUI_SRCS
qgsattributetypeloaddialog.cpp
qgsblendmodecombobox.cpp
qgsbrowsertreeview.cpp
qgsbrowserdockwidget.cpp
qgsbusyindicatordialog.cpp
qgscharacterselectordialog.cpp
qgscheckablecombobox.cpp
@@ -362,6 +363,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsdial.h
qgsdialog.h
qgsdockwidget.h
qgsbrowserdockwidget.h
qgsencodingfiledialog.h
qgserrordialog.h
qgsexpressionbuilderdialog.h
@@ -648,6 +650,7 @@ SET(QGIS_GUI_HDRS
qgssqlcomposerdialog.h
qgstablewidgetitem.h
qgsuserinputdockwidget.h
qgsbrowserdockwidget.h
qgsvertexmarker.h
qgsfiledownloader.h

@@ -23,7 +23,6 @@
#include <QPlainTextDocumentLayout>
#include <QSortFilterProxyModel>

#include "qgisapp.h"
#include "qgsbrowsermodel.h"
#include "qgsbrowsertreeview.h"
#include "qgslogger.h"
@@ -337,9 +336,6 @@ void QgsBrowserDockWidget::showEvent( QShowEvent *e )
if ( !mModel )
{
mModel = new QgsBrowserModel( mBrowserView );

connect( QgisApp::instance(), &QgisApp::newProject, mModel, &QgsBrowserModel::updateProjectHome );

mProxyModel = new QgsBrowserTreeFilterProxyModel( this );
mProxyModel->setBrowserModel( mModel );
mBrowserView->setSettingsSection( objectName().toLower() ); // to distinguish 2 instances ow browser
@@ -515,7 +511,7 @@ void QgsBrowserDockWidget::addLayer( QgsLayerItem *layerItem )

QgsMimeDataUtils::UriList list;
list << layerItem->mimeUri();
QgisApp::instance()->handleDropUriList( list );
emit handleDropUriList( list );
}

void QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex &index )
@@ -529,7 +525,7 @@ void QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex &index )
if ( projectItem )
{
QApplication::setOverrideCursor( Qt::WaitCursor );
QgisApp::instance()->openFile( projectItem->path() );
emit openFile( projectItem->path() );
QApplication::restoreOverrideCursor();
}
}
@@ -561,7 +557,7 @@ void QgsBrowserDockWidget::addSelectedLayers()
{
QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
if ( projectItem )
QgisApp::instance()->openFile( projectItem->path() );
emit openFile( projectItem->path() );

QApplication::restoreOverrideCursor();
return;
@@ -657,6 +653,11 @@ void QgsBrowserDockWidget::setFilter()
mProxyModel->setFilter( filter );
}

void QgsBrowserDockWidget::updateProjectHome()
{
if (mModel) mModel->updateProjectHome();
}

void QgsBrowserDockWidget::setFilterSyntax( QAction *action )
{
if ( !action || ! mProxyModel )
@@ -23,8 +23,8 @@
#include "qgsdataitem.h"
#include "qgsbrowsertreeview.h"
#include "qgsdockwidget.h"
#include "qgis_gui.h"
#include <QSortFilterProxyModel>
#include "qgis_app.h"

class QgsBrowserModel;
class QModelIndex;
@@ -101,7 +101,7 @@ class QgsBrowserPropertiesDialog : public QDialog, private Ui::QgsBrowserPropert
QString mSettingsSection;
};

class APP_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBrowserDockWidgetBase
class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBrowserDockWidgetBase
{
Q_OBJECT
public:
@@ -124,6 +124,8 @@ class APP_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBro
void setFilterSyntax( QAction * );
void setCaseSensitive( bool caseSensitive );
void setFilter();
void updateProjectHome();


// layer menu items
void addSelectedLayers();
@@ -134,6 +136,12 @@ class APP_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBro
void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
void splitterMoved();

signals:
// A file needs to be opened
void openFile( const QString );
// Drop uri list needs to be handled
void handleDropUriList( QgsMimeDataUtils::UriList );

protected:
void refreshModel( const QModelIndex &index );
void showEvent( QShowEvent *event ) override;

0 comments on commit f250b19

Please sign in to comment.
You can’t perform that action at this time.