Skip to content

Commit

Permalink
rename stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 12, 2022
1 parent f54136e commit ff5bde7
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 85 deletions.
18 changes: 9 additions & 9 deletions python/core/auto_generated/project/qgsmapviewsmanager.sip.in
Expand Up @@ -57,28 +57,28 @@ Removes and deletes all views from the manager.



void removeView( const QString &name );
void remove3DView( const QString &name );
%Docstring
Removes the configuration of the view named ``name``
Removes the configuration of the 3D view named ``name``
%End

void renameView( const QString &oldTitle, const QString &newTitle );
void rename3DView( const QString &oldTitle, const QString &newTitle );
%Docstring
Renames the view named ``oldTitle`` to ``newTitle``
Renames the 3D view named ``oldTitle`` to ``newTitle``
%End

void setViewInitiallyVisible( const QString &name, bool visible );
void set3DViewInitiallyVisible( const QString &name, bool visible );
%Docstring
Sets whether the view named ``name`` will be initially visible when the project is opened
Sets whether the 3D view named ``name`` will be initially visible when the project is opened
%End

bool isViewOpen( const QString &name );
bool is3DViewOpen( const QString &name );
%Docstring
Returns whether the view named ``name`` will is opened
Returns whether the 3D view named ``name`` will is opened
%End

signals:
void viewsListChanged();
void views3DListChanged();
%Docstring
Emitted when the views list has changed (whenever a view was removed, added, renamed..)
%End
Expand Down
4 changes: 2 additions & 2 deletions python/core/auto_generated/project/qgsproject.sip.in
Expand Up @@ -745,9 +745,9 @@ the project.
%End


QgsMapViewsManager *get3DViewsManager();
QgsMapViewsManager *getViewsManager();
%Docstring
Returns the project's 3D views manager, which manages 3D views
Returns the project's views manager, which manages map views (including 3d maps)
in the project.

.. versionadded:: 3.24
Expand Down
13 changes: 6 additions & 7 deletions src/app/3d/qgs3dviewsmanagerdialog.cpp
Expand Up @@ -46,12 +46,12 @@ Qgs3DViewsManagerDialog::Qgs3DViewsManagerDialog( QWidget *parent, Qt::WindowFla

connect( m3DViewsListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &Qgs3DViewsManagerDialog::currentChanged );

connect( QgsProject::instance()->get3DViewsManager(), &QgsMapViewsManager::viewsListChanged, this, &Qgs3DViewsManagerDialog::onViewsListChanged );
connect( QgsProject::instance()->get3DViewsManager(), &QgsMapViewsManager::views3DListChanged, this, &Qgs3DViewsManagerDialog::on3DViewsListChanged );
m3DViewsListView->selectionModel()->setCurrentIndex( m3DViewsListView->model()->index( 0, 0 ), QItemSelectionModel::Select );
currentChanged( m3DViewsListView->selectionModel()->currentIndex(), m3DViewsListView->selectionModel()->currentIndex() );
}

void Qgs3DViewsManagerDialog::onViewsListChanged()
void Qgs3DViewsManagerDialog::on3DViewsListChanged()
{
reload();
}
Expand Down Expand Up @@ -116,7 +116,7 @@ void Qgs3DViewsManagerDialog::removeClicked()

QString viewName = m3DViewsListView->selectionModel()->selectedRows().at( 0 ).data( Qt::DisplayRole ).toString();

QgsProject::instance()->get3DViewsManager()->removeView( viewName );
QgsProject::instance()->get3DViewsManager()->remove3DView( viewName );
if ( Qgs3DMapCanvasDockWidget *w = QgisApp::instance()->get3DMapViewDock( viewName ) )
{
w->close();
Expand All @@ -135,7 +135,7 @@ void Qgs3DViewsManagerDialog::renameClicked()
if ( newTitle.isEmpty() )
return;

QgsProject::instance()->get3DViewsManager()->renameView( oldTitle, newTitle );
QgsProject::instance()->get3DViewsManager()->rename3DView( oldTitle, newTitle );

if ( Qgs3DMapCanvasDockWidget *widget = QgisApp::instance()->get3DMapViewDock( oldTitle ) )
{
Expand All @@ -161,15 +161,14 @@ void Qgs3DViewsManagerDialog::currentChanged( const QModelIndex &current, const
}

QString viewName = current.data( Qt::DisplayRole ).toString();
bool isOpen = QgsProject::instance()->get3DViewsManager()->isViewOpen( viewName );
bool isOpen = QgsProject::instance()->get3DViewsManager()->is3DViewOpen( viewName );
mShowButton->setEnabled( !isOpen );
mHideButton->setEnabled( isOpen );
}

void Qgs3DViewsManagerDialog::reload()
{
QStringList names = QgsProject::instance()->get3DViewsManager()->getViewsNames();
qDebug() << __PRETTY_FUNCTION__ << " " << names;
QStringList names = QgsProject::instance()->get3DViewsManager()->get3DViewsNames();
mListModel->setStringList( names );
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/3d/qgs3dviewsmanagerdialog.h
Expand Up @@ -42,7 +42,7 @@ class Qgs3DViewsManagerDialog : public QDialog, private Ui::Qgs3DViewsManagerDia

void currentChanged( const QModelIndex &current, const QModelIndex &previous );

void onViewsListChanged();
void on3DViewsListChanged();
private:
QStringListModel *mListModel = nullptr;

Expand Down
30 changes: 15 additions & 15 deletions src/app/qgisapp.cpp
Expand Up @@ -1746,7 +1746,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers
setupLayoutManagerConnections();

#ifdef HAVE_3D
connect( QgsProject::instance()->get3DViewsManager(), &QgsMapViewsManager::viewsListChanged, this, &QgisApp::views3DMenuAboutToShow );
connect( QgsProject::instance()->getViewsManager(), &QgsMapViewsManager::views3DListChanged, this, &QgisApp::views3DMenuAboutToShow );
#endif

setupDuplicateFeaturesAction();
Expand Down Expand Up @@ -9903,7 +9903,7 @@ Qgs3DMapCanvasDockWidget *QgisApp::open3DMapView( const QString &viewName )
QgsReadWriteContext readWriteContext;
readWriteContext.setPathResolver( QgsProject::instance()->pathResolver() );

QDomElement elem3DMap = QgsProject::instance()->get3DViewsManager()->getViewSettings( viewName );
QDomElement elem3DMap = QgsProject::instance()->getViewsManager()->get3DViewSettings( viewName );

if ( elem3DMap.isNull() )
return nullptr;
Expand All @@ -9915,7 +9915,7 @@ Qgs3DMapCanvasDockWidget *QgisApp::open3DMapView( const QString &viewName )
read3DMapViewSettings( mapCanvasDock3D, elem3DMap );
mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );

QgsProject::instance()->get3DViewsManager()->setViewInitiallyVisible( viewName, true );
QgsProject::instance()->getViewsManager()->set3DViewInitiallyVisible( viewName, true );

return mapCanvasDock3D;
#else
Expand Down Expand Up @@ -9962,7 +9962,7 @@ Qgs3DMapCanvasDockWidget *QgisApp::duplicate3DMapView( const QString &existingVi
}
else
{
QDomElement elem = QgsProject::instance()->get3DViewsManager()->getViewSettings( existingViewName );
QDomElement elem = QgsProject::instance()->getViewsManager()->get3DViewSettings( existingViewName );
elem.setAttribute( QStringLiteral( "name" ), newViewName );
read3DMapViewSettings( mapCanvasDock3D, elem );
}
Expand All @@ -9973,8 +9973,8 @@ Qgs3DMapCanvasDockWidget *QgisApp::duplicate3DMapView( const QString &existingVi
elem3DMap = doc.createElement( QStringLiteral( "view" ) );
write3DMapViewSettings( mapCanvasDock3D, doc, elem3DMap );

QgsProject::instance()->get3DViewsManager()->registerViewSettings( newViewName, elem3DMap );
QgsProject::instance()->get3DViewsManager()->setViewInitiallyVisible( newViewName, true );
QgsProject::instance()->getViewsManager()->register3DViewSettings( newViewName, elem3DMap );
QgsProject::instance()->getViewsManager()->set3DViewInitiallyVisible( newViewName, true );

mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );

Expand Down Expand Up @@ -10091,7 +10091,7 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu )
#ifdef HAVE_3D
menu->clear();
QList<QAction *> acts;
QList< QDomElement > views = QgsProject::instance()->get3DViewsManager()->getViews();
QList< QDomElement > views = QgsProject::instance()->getViewsManager()->get3DViews();
acts.reserve( views.size() );
for ( const QDomElement &viewConfig : views )
{
Expand Down Expand Up @@ -13988,14 +13988,14 @@ Qgs3DMapCanvasDockWidget *QgisApp::createNew3DMapCanvasDock( const QString &name
QDomDocument doc( documentType );

QString viewName = map3DWidget->mapCanvas3D()->objectName();
if ( !QgsProject::instance()->get3DViewsManager()->getViewSettings( viewName ).isNull() )
if ( !QgsProject::instance()->getViewsManager()->get3DViewSettings( viewName ).isNull() )
{
QDomElement elem3DMap;
elem3DMap = doc.createElement( QStringLiteral( "view" ) );
write3DMapViewSettings( map3DWidget, doc, elem3DMap );

QgsProject::instance()->get3DViewsManager()->registerViewSettings( viewName, elem3DMap );
QgsProject::instance()->get3DViewsManager()->setViewInitiallyVisible( viewName, false );
QgsProject::instance()->getViewsManager()->register3DViewSettings( viewName, elem3DMap );
QgsProject::instance()->getViewsManager()->set3DViewInitiallyVisible( viewName, false );
}
QgisApp::instance()->mOpen3DDocks.remove( map3DWidget );
} );
Expand Down Expand Up @@ -14028,7 +14028,7 @@ void QgisApp::new3DMapCanvas()
}

int i = 1;
const QList< QString > usedCanvasNames = QgsProject::instance()->get3DViewsManager()->getViewsNames();
const QList< QString > usedCanvasNames = QgsProject::instance()->getViewsManager()->get3DViewsNames();
QString name = tr( "3D Map %1" ).arg( i );
while ( usedCanvasNames.contains( name ) )
{
Expand Down Expand Up @@ -14104,8 +14104,8 @@ void QgisApp::new3DMapCanvas()

write3DMapViewSettings( dock, doc, elem3DMap );

QgsProject::instance()->get3DViewsManager()->registerViewSettings( name, elem3DMap );
QgsProject::instance()->get3DViewsManager()->setViewInitiallyVisible( name, true );
QgsProject::instance()->getViewsManager()->register3DViewSettings( name, elem3DMap );
QgsProject::instance()->getViewsManager()->set3DViewInitiallyVisible( name, true );

mPanelMenu->removeAction( dock->toggleViewAction() );
}
Expand Down Expand Up @@ -16813,7 +16813,7 @@ void QgisApp::writeProject( QDomDocument &doc )
QDomElement elem3DMap = doc.createElement( QStringLiteral( "view" ) );
elem3DMap.setAttribute( QStringLiteral( "isOpen" ), 1 );
write3DMapViewSettings( widget, doc, elem3DMap );
QgsProject::instance()->get3DViewsManager()->registerViewSettings( viewName, elem3DMap );
QgsProject::instance()->getViewsManager()->register3DViewSettings( viewName, elem3DMap );
}
#endif
projectChanged( doc );
Expand Down Expand Up @@ -16924,7 +16924,7 @@ void QgisApp::readProject( const QDomDocument &doc )

#ifdef HAVE_3D
// Open 3D Views that were already open
for ( QDomElement viewConfig : QgsProject::instance()->get3DViewsManager()->getViews() )
for ( QDomElement viewConfig : QgsProject::instance()->getViewsManager()->get3DViews() )
{
QString viewName = viewConfig.attribute( QStringLiteral( "name" ) );
bool isOpen = viewConfig.attribute( QStringLiteral( "isOpen" ), QStringLiteral( "1" ) ).toInt() == 1;
Expand Down
54 changes: 27 additions & 27 deletions src/core/project/qgsmapviewsmanager.cpp
Expand Up @@ -36,7 +36,7 @@ bool QgsMapViewsManager::readXml( const QDomElement &element, const QDomDocument
while ( !elem3DMap.isNull() )
{
QString mapName = elem3DMap.attribute( QStringLiteral( "name" ) );
mMapViewsDom.insert( mapName, elem3DMap );
m3DMapViewsDom.insert( mapName, elem3DMap );

elem3DMap = elem3DMap.nextSiblingElement( QStringLiteral( "view" ) );
}
Expand All @@ -48,62 +48,62 @@ bool QgsMapViewsManager::readXml( const QDomElement &element, const QDomDocument
QDomElement QgsMapViewsManager::writeXml( QDomDocument &doc ) const
{
QDomElement dom = doc.createElement( "mapViewDocks3D" );
for ( QDomElement d : mMapViewsDom.values() )
for ( QDomElement d : m3DMapViewsDom.values() )
dom.appendChild( d );
return dom;
}

void QgsMapViewsManager::clear()
{
mMapViewsDom.clear();
emit viewsListChanged();
m3DMapViewsDom.clear();
emit views3DListChanged();
}

QDomElement QgsMapViewsManager::getViewSettings( const QString &name ) const
QDomElement QgsMapViewsManager::get3DViewSettings( const QString &name ) const
{
return mMapViewsDom.value( name, QDomElement() );
return m3DMapViewsDom.value( name, QDomElement() );
}

QList<QDomElement> QgsMapViewsManager::getViews() const
QList<QDomElement> QgsMapViewsManager::get3DViews() const
{
return mMapViewsDom.values();
return m3DMapViewsDom.values();
}

void QgsMapViewsManager::registerViewSettings( const QString &name, const QDomElement &dom )
void QgsMapViewsManager::register3DViewSettings( const QString &name, const QDomElement &dom )
{
mMapViewsDom.insert( name, dom );
emit viewsListChanged();
m3DMapViewsDom.insert( name, dom );
emit views3DListChanged();
}

QStringList QgsMapViewsManager::getViewsNames() const
QStringList QgsMapViewsManager::get3DViewsNames() const
{
return mMapViewsDom.keys();
return m3DMapViewsDom.keys();
}

void QgsMapViewsManager::removeView( const QString &name )
void QgsMapViewsManager::remove3DView( const QString &name )
{
mMapViewsDom.remove( name );
emit viewsListChanged();
m3DMapViewsDom.remove( name );
emit views3DListChanged();
}

void QgsMapViewsManager::renameView( const QString &oldTitle, const QString &newTitle )
void QgsMapViewsManager::rename3DView( const QString &oldTitle, const QString &newTitle )
{
QDomElement elem = mMapViewsDom.value( oldTitle );
mMapViewsDom.remove( oldTitle );
mMapViewsDom[ newTitle ] = elem;
mMapViewsDom[ newTitle ].setAttribute( QStringLiteral( "name" ), newTitle );
emit viewsListChanged();
QDomElement elem = m3DMapViewsDom.value( oldTitle );
m3DMapViewsDom.remove( oldTitle );
m3DMapViewsDom[ newTitle ] = elem;
m3DMapViewsDom[ newTitle ].setAttribute( QStringLiteral( "name" ), newTitle );
emit views3DListChanged();
}

void QgsMapViewsManager::setViewInitiallyVisible( const QString &name, bool visible )
void QgsMapViewsManager::set3DViewInitiallyVisible( const QString &name, bool visible )
{
if ( mMapViewsDom.contains( name ) )
if ( m3DMapViewsDom.contains( name ) )
{
mMapViewsDom[ name ].setAttribute( QStringLiteral( "isOpen" ), visible );
m3DMapViewsDom[ name ].setAttribute( QStringLiteral( "isOpen" ), visible );
}
}

bool QgsMapViewsManager::isViewOpen( const QString &name )
bool QgsMapViewsManager::is3DViewOpen( const QString &name )
{
return mMapViewsDom.value( name, QDomElement() ).attribute( QStringLiteral( "isOpen" ), QStringLiteral( "1" ) ).toInt() == 1;
return m3DMapViewsDom.value( name, QDomElement() ).attribute( QStringLiteral( "isOpen" ), QStringLiteral( "1" ) ).toInt() == 1;
}
36 changes: 18 additions & 18 deletions src/core/project/qgsmapviewsmanager.h
Expand Up @@ -66,51 +66,51 @@ class CORE_EXPORT QgsMapViewsManager : public QObject
void clear();

/**
* Returns the DOM element representing the settings of the view named \a name
* Returns the DOM element representing the settings of the 3D view named \a name
*
* \note Not available in Python bindings
*/
QDomElement getViewSettings( const QString &name ) const SIP_SKIP;
QDomElement get3DViewSettings( const QString &name ) const SIP_SKIP;

/**
* Adds a new view named \a name to the manager with the configuration DOM \a dom
* Adds a new 3D view named \a name to the manager with the configuration DOM \a dom
*
* \note Not available in Python bindings
*/
void registerViewSettings( const QString &name, const QDomElement &dom ) SIP_SKIP;
void register3DViewSettings( const QString &name, const QDomElement &dom ) SIP_SKIP;

/**
* Returns the names of all views added to the manager
* Returns the names of all 3D views added to the manager
*
* \note Not available in Python bindings
*/
QStringList getViewsNames() const SIP_SKIP;
QStringList get3DViewsNames() const SIP_SKIP;

/**
* Returns the list of configurations of views added to the manager
* Returns the list of configurations of 3D views added to the manager
*
* \note Not available in Python bindings
*/
QList<QDomElement> getViews() const SIP_SKIP;
QList<QDomElement> get3DViews() const SIP_SKIP;

//! Removes the configuration of the view named \a name
void removeView( const QString &name );
//! Removes the configuration of the 3D view named \a name
void remove3DView( const QString &name );

//! Renames the view named \a oldTitle to \a newTitle
void renameView( const QString &oldTitle, const QString &newTitle );
//! Renames the 3D view named \a oldTitle to \a newTitle
void rename3DView( const QString &oldTitle, const QString &newTitle );

//! Sets whether the view named \a name will be initially visible when the project is opened
void setViewInitiallyVisible( const QString &name, bool visible );
//! Sets whether the 3D view named \a name will be initially visible when the project is opened
void set3DViewInitiallyVisible( const QString &name, bool visible );

//! Returns whether the view named \a name will is opened
bool isViewOpen( const QString &name );
//! Returns whether the 3D view named \a name will is opened
bool is3DViewOpen( const QString &name );

signals:
//! Emitted when the views list has changed (whenever a view was removed, added, renamed..)
void viewsListChanged();
void views3DListChanged();

private:
QMap<QString, QDomElement> mMapViewsDom;
QMap<QString, QDomElement> m3DMapViewsDom;
};


Expand Down

0 comments on commit ff5bde7

Please sign in to comment.