Skip to content
Permalink
Browse files

Added optional argument to keep legacy API and behavior

  • Loading branch information
elpaso committed Sep 20, 2017
1 parent ccdda89 commit f8b2b138751d23345c8ced37c2ccf0eb244bd14f
Showing with 19 additions and 4 deletions.
  1. +7 −1 python/core/qgsbrowsermodel.sip
  2. +2 −1 src/app/qgisapp.cpp
  3. +3 −1 src/core/qgsbrowsermodel.cpp
  4. +7 −1 src/core/qgsbrowsermodel.h
@@ -5,7 +5,7 @@ class QgsBrowserModel : QAbstractItemModel
%End

public:
explicit QgsBrowserModel( QObject *parent = 0 );
explicit QgsBrowserModel( QObject *parent = 0, bool initialize = true );
~QgsBrowserModel();

enum ItemDataRole
@@ -81,6 +81,12 @@ class QgsBrowserModel : QAbstractItemModel
bool canFetchMore( const QModelIndex & parent ) const;
void fetchMore( const QModelIndex & parent );

//! Returns true if the model has been initialized
bool initialized( );

//! Delayed initialization
void init();

signals:
/** Emitted when item children fetch was finished */
void stateChanged( const QModelIndex & index, QgsDataItem::State oldState );
@@ -804,7 +804,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mSnappingDialog->setObjectName( "SnappingOption" );
endProfile();

mBrowserModel = new QgsBrowserModel( this );
// Create the (shared) model with delayed initialization
mBrowserModel = new QgsBrowserModel( this, false );
mBrowserWidget = new QgsBrowserDockWidget( tr( "Browser Panel" ), mBrowserModel, this );
mBrowserWidget->setObjectName( "Browser" );
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget );
@@ -47,12 +47,14 @@ static bool cmpByDataItemName_( QgsDataItem* a, QgsDataItem* b )
return QString::localeAwareCompare( a->name(), b->name() ) < 0;
}

QgsBrowserModel::QgsBrowserModel( QObject *parent )
QgsBrowserModel::QgsBrowserModel( QObject *parent, bool initialize )
: QAbstractItemModel( parent )
, mFavourites( nullptr )
, mProjectHome( nullptr )
, mInitialized( false )
{
if ( initialize )
init();
}

QgsBrowserModel::~QgsBrowserModel()
@@ -53,7 +53,13 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
Q_OBJECT

public:
explicit QgsBrowserModel( QObject *parent = nullptr );

/**
* @brief QgsBrowserModel
* @param parent
* @param initialize immediately called init, default to true
*/
explicit QgsBrowserModel( QObject *parent = nullptr , bool initialize = true );
~QgsBrowserModel();

enum ItemDataRole

0 comments on commit f8b2b13

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