mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -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 ) )
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
QMessageBox::critical( this,
|
||||
tr( "Unable to open project" ),
|
||||
QgsProject::instance()->error() );
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
mMapCanvas->freeze( false );
|
||||
mMapCanvas->refresh();
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgisapp.h"
|
||||
#include "qgsproject.h"
|
||||
|
||||
// browser layer properties dialog
|
||||
#include "qgsapplication.h"
|
||||
@ -285,6 +286,10 @@ void QgsBrowserDockWidget::showEvent( QShowEvent * e )
|
||||
if ( item && item->type() == QgsDataItem::Favourites )
|
||||
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 );
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "qgsproviderregistry.h"
|
||||
|
||||
#include "qgsbrowsermodel.h"
|
||||
#include "qgsproject.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
@ -40,8 +41,18 @@ QgsBrowserModel::~QgsBrowserModel()
|
||||
|
||||
void QgsBrowserModel::addRootItems()
|
||||
{
|
||||
// give the home directory a prominent first place
|
||||
QgsDirectoryItem *item = new QgsDirectoryItem( NULL, tr( "Home" ), QDir::homePath() );
|
||||
QgsDirectoryItem *item;
|
||||
|
||||
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();
|
||||
QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) );
|
||||
item->setIcon( homeIcon );
|
||||
|
@ -75,9 +75,6 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
|
||||
|
||||
bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
|
||||
|
||||
// Reload the whole model
|
||||
void reload();
|
||||
|
||||
// Refresh item specified by path
|
||||
void refresh( QString path );
|
||||
|
||||
@ -93,6 +90,8 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
|
||||
void fetchMore( const QModelIndex & parent );
|
||||
|
||||
public slots:
|
||||
// Reload the whole model
|
||||
void reload();
|
||||
|
||||
void beginInsertItems( QgsDataItem *parent, int first, int last );
|
||||
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",
|
||||
// where the source file had to exist and only the project directory was stripped
|
||||
// from the filename.
|
||||
QFileInfo pfi( fileName() );
|
||||
if ( !pfi.exists() )
|
||||
QString home = homePath();
|
||||
if( home.isNull() )
|
||||
return src;
|
||||
|
||||
QFileInfo fi( pfi.canonicalPath() + "/" + src );
|
||||
QFileInfo fi( home + "/" + src );
|
||||
|
||||
if ( !fi.exists() )
|
||||
{
|
||||
@ -1763,4 +1763,11 @@ void QgsProjectBadLayerDefaultHandler::handleBadLayers( QList<QDomNode> /*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*/
|
||||
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:
|
||||
|
||||
/** Set error message from read/write operation
|
||||
|
@ -58,8 +58,8 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl, bool ma
|
||||
: QDialog( parent, fl )
|
||||
, mManagerMode( managerMode )
|
||||
, mEmbeddedMode( embeddedMode )
|
||||
, mCurrentTileset( 0 )
|
||||
, mDefaultCRS( GEO_EPSG_CRS_AUTHID )
|
||||
, mCurrentTileset( 0 )
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user