mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Include project home in browser toplevel browser (implement #6955)
[API] add QgsProject::homePath() [API] make QgsBrowserModel::reload() a public slot
This commit is contained in:
parent
314d144b4d
commit
73dc9b19be
@ -3330,11 +3330,12 @@ bool QgisApp::addProject( QString projectFile )
|
|||||||
|
|
||||||
if ( ! QgsProject::instance()->read( projectFile ) )
|
if ( ! QgsProject::instance()->read( projectFile ) )
|
||||||
{
|
{
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
QMessageBox::critical( this,
|
QMessageBox::critical( this,
|
||||||
tr( "Unable to open project" ),
|
tr( "Unable to open project" ),
|
||||||
QgsProject::instance()->error() );
|
QgsProject::instance()->error() );
|
||||||
|
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
|
|
||||||
mMapCanvas->freeze( false );
|
mMapCanvas->freeze( false );
|
||||||
mMapCanvas->refresh();
|
mMapCanvas->refresh();
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "qgsrasterlayer.h"
|
#include "qgsrasterlayer.h"
|
||||||
#include "qgsvectorlayer.h"
|
#include "qgsvectorlayer.h"
|
||||||
#include "qgisapp.h"
|
#include "qgisapp.h"
|
||||||
|
#include "qgsproject.h"
|
||||||
|
|
||||||
// browser layer properties dialog
|
// browser layer properties dialog
|
||||||
#include "qgsapplication.h"
|
#include "qgsapplication.h"
|
||||||
@ -285,6 +286,10 @@ void QgsBrowserDockWidget::showEvent( QShowEvent * e )
|
|||||||
if ( item && item->type() == QgsDataItem::Favourites )
|
if ( item && item->type() == QgsDataItem::Favourites )
|
||||||
mBrowserView->expand( index );
|
mBrowserView->expand( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect( QgsProject::instance(), SIGNAL( readProject( const QDomDocument & ) ), mModel, SLOT( reload() ) );
|
||||||
|
connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument & ) ), mModel, SLOT( reload() ) );
|
||||||
|
connect( QgisApp::instance(), SIGNAL( newProject() ), mModel, SLOT( reload() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDockWidget::showEvent( e );
|
QDockWidget::showEvent( e );
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "qgsproviderregistry.h"
|
#include "qgsproviderregistry.h"
|
||||||
|
|
||||||
#include "qgsbrowsermodel.h"
|
#include "qgsbrowsermodel.h"
|
||||||
|
#include "qgsproject.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
@ -40,8 +41,18 @@ QgsBrowserModel::~QgsBrowserModel()
|
|||||||
|
|
||||||
void QgsBrowserModel::addRootItems()
|
void QgsBrowserModel::addRootItems()
|
||||||
{
|
{
|
||||||
// give the home directory a prominent first place
|
QgsDirectoryItem *item;
|
||||||
QgsDirectoryItem *item = new QgsDirectoryItem( NULL, tr( "Home" ), QDir::homePath() );
|
|
||||||
|
QString home = QgsProject::instance()->homePath();
|
||||||
|
|
||||||
|
if( !home.isNull() )
|
||||||
|
{
|
||||||
|
item = new QgsDirectoryItem( NULL, tr( "Project home" ), home );
|
||||||
|
mRootItems << item;
|
||||||
|
}
|
||||||
|
|
||||||
|
// give the home directory a prominent second place
|
||||||
|
item = new QgsDirectoryItem( NULL, tr( "Home" ), QDir::homePath() );
|
||||||
QStyle *style = QApplication::style();
|
QStyle *style = QApplication::style();
|
||||||
QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) );
|
QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) );
|
||||||
item->setIcon( homeIcon );
|
item->setIcon( homeIcon );
|
||||||
|
@ -75,9 +75,6 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
|
|||||||
|
|
||||||
bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
|
bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
|
||||||
|
|
||||||
// Reload the whole model
|
|
||||||
void reload();
|
|
||||||
|
|
||||||
// Refresh item specified by path
|
// Refresh item specified by path
|
||||||
void refresh( QString path );
|
void refresh( QString path );
|
||||||
|
|
||||||
@ -93,6 +90,8 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
|
|||||||
void fetchMore( const QModelIndex & parent );
|
void fetchMore( const QModelIndex & parent );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
// Reload the whole model
|
||||||
|
void reload();
|
||||||
|
|
||||||
void beginInsertItems( QgsDataItem *parent, int first, int last );
|
void beginInsertItems( QgsDataItem *parent, int first, int last );
|
||||||
void endInsertItems();
|
void endInsertItems();
|
||||||
|
@ -1368,11 +1368,11 @@ QString QgsProject::readPath( QString src ) const
|
|||||||
// That means that it was saved with an earlier version of "relative path support",
|
// That means that it was saved with an earlier version of "relative path support",
|
||||||
// where the source file had to exist and only the project directory was stripped
|
// where the source file had to exist and only the project directory was stripped
|
||||||
// from the filename.
|
// from the filename.
|
||||||
QFileInfo pfi( fileName() );
|
QString home = homePath();
|
||||||
if ( !pfi.exists() )
|
if( home.isNull() )
|
||||||
return src;
|
return src;
|
||||||
|
|
||||||
QFileInfo fi( pfi.canonicalPath() + "/" + src );
|
QFileInfo fi( home + "/" + src );
|
||||||
|
|
||||||
if ( !fi.exists() )
|
if ( !fi.exists() )
|
||||||
{
|
{
|
||||||
@ -1763,4 +1763,11 @@ void QgsProjectBadLayerDefaultHandler::handleBadLayers( QList<QDomNode> /*layers
|
|||||||
// just ignore any bad layers
|
// just ignore any bad layers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QgsProject::homePath() const
|
||||||
|
{
|
||||||
|
QFileInfo pfi( fileName() );
|
||||||
|
if ( !pfi.exists() )
|
||||||
|
return QString::null;
|
||||||
|
|
||||||
|
return pfi.canonicalPath();
|
||||||
|
}
|
||||||
|
@ -310,6 +310,11 @@ class CORE_EXPORT QgsProject : public QObject
|
|||||||
@note added in version 1.9*/
|
@note added in version 1.9*/
|
||||||
bool topologicalEditing() const;
|
bool topologicalEditing() const;
|
||||||
|
|
||||||
|
/** Return project's home path
|
||||||
|
@return home path of project (or QString::null if not set)
|
||||||
|
@note added in version 2.0 */
|
||||||
|
QString homePath() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** Set error message from read/write operation
|
/** Set error message from read/write operation
|
||||||
|
@ -58,8 +58,8 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl, bool ma
|
|||||||
: QDialog( parent, fl )
|
: QDialog( parent, fl )
|
||||||
, mManagerMode( managerMode )
|
, mManagerMode( managerMode )
|
||||||
, mEmbeddedMode( embeddedMode )
|
, mEmbeddedMode( embeddedMode )
|
||||||
, mCurrentTileset( 0 )
|
|
||||||
, mDefaultCRS( GEO_EPSG_CRS_AUTHID )
|
, mDefaultCRS( GEO_EPSG_CRS_AUTHID )
|
||||||
|
, mCurrentTileset( 0 )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user