Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d6b062
commit f49a268
Showing
11 changed files
with
586 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#include "qgs3dviewsmanager.h" | ||
|
||
#include "qgs3dmapcanvasdockwidget.h" | ||
#include <QDebug> | ||
#include "qgsnewnamedialog.h" | ||
#include "qgisapp.h" | ||
|
||
Qgs3DViewsManager::Qgs3DViewsManager( QWidget *parent, Qt::WindowFlags f ) | ||
: QDialog( parent, f ) | ||
{ | ||
setupUi( this ); | ||
m3DViewsListView->setModel( &mListModel ); | ||
|
||
m3DViewsListView->setEditTriggers( QAbstractItemView::NoEditTriggers ); | ||
m3DViewsListView->setSelectionMode( QAbstractItemView::SingleSelection ); | ||
|
||
connect( m3DViewsListView, &QListView::clicked, [&]( const QModelIndex & index ) | ||
{ | ||
mSelectedViewIndex = index.row(); | ||
} ); | ||
|
||
connect( mShowButton, &QToolButton::clicked, [&]() | ||
{ | ||
if ( mSelectedViewIndex == -1 ) | ||
return; | ||
QString viewName = mListModel.stringList()[ mSelectedViewIndex ]; | ||
Qgs3DMapCanvasDockWidget *widget = m3DMapViewsWidgets->value( viewName, nullptr ); | ||
if ( !widget ) | ||
{ | ||
widget = QgisApp::instance()->open3DMapView( viewName ); | ||
} | ||
if ( widget ) | ||
{ | ||
widget->show(); | ||
widget->activateWindow(); | ||
widget->raise(); | ||
} | ||
} ); | ||
|
||
connect( mRenameButton, &QToolButton::clicked, [&]() | ||
{ | ||
if ( mSelectedViewIndex == -1 ) | ||
return; | ||
QString oldTitle = mListModel.stringList()[ mSelectedViewIndex ]; | ||
|
||
QString newTitle; | ||
QgsNewNameDialog dlg( QStringLiteral( "3D view" ), newTitle, QStringList(), m3DMapViewsDom->keys(), Qt::CaseSensitive, this ); | ||
dlg.setWindowTitle( "Title" ); | ||
dlg.setHintString( "" ); | ||
dlg.setOverwriteEnabled( false ); | ||
dlg.setAllowEmptyName( false ); | ||
dlg.setConflictingNameWarning( tr( "Title already exists!" ) ); | ||
|
||
if ( dlg.exec() != QDialog::Accepted ) | ||
return; | ||
newTitle = dlg.name(); | ||
|
||
QDomElement dom = m3DMapViewsDom->value( oldTitle ); | ||
m3DMapViewsDom->remove( oldTitle ); | ||
m3DMapViewsDom->insert( newTitle, dom ); | ||
Qgs3DMapCanvasDockWidget *widget = m3DMapViewsWidgets->value( oldTitle, nullptr ); | ||
if ( widget ) | ||
{ | ||
m3DMapViewsWidgets->remove( oldTitle ); | ||
m3DMapViewsWidgets->insert( newTitle, widget ); | ||
widget->setName( newTitle ); | ||
} | ||
reloadListModel(); | ||
} ); | ||
|
||
connect( mDuplicateButton, &QToolButton::clicked, [&]() | ||
{ | ||
if ( mSelectedViewIndex == -1 ) | ||
return; | ||
|
||
QString viewName = mListModel.stringList()[ mSelectedViewIndex ] + "_"; | ||
|
||
Qgs3DMapCanvasDockWidget *widget = QgisApp::instance()->duplicate3DMapView( mListModel.stringList()[ mSelectedViewIndex ] ); | ||
if ( widget ) | ||
{ | ||
widget->show(); | ||
widget->activateWindow(); | ||
widget->raise(); | ||
} | ||
reloadListModel(); | ||
} ); | ||
|
||
connect( mRemoveButton, &QToolButton::clicked, [&]() | ||
{ | ||
if ( mSelectedViewIndex == -1 ) | ||
return; | ||
QString viewName = mListModel.stringList()[ mSelectedViewIndex ]; | ||
m3DMapViewsDom->remove( viewName ); | ||
Qgs3DMapCanvasDockWidget *w = ( *m3DMapViewsWidgets )[ viewName ]; | ||
m3DMapViewsWidgets->remove( viewName ); | ||
w->close(); | ||
reloadListModel(); | ||
} ); | ||
} | ||
|
||
Qgs3DViewsManager::~Qgs3DViewsManager() | ||
{ | ||
} | ||
|
||
void Qgs3DViewsManager::reload() | ||
{ | ||
if ( !m3DMapViewsDom || !m3DMapViewsWidgets ) | ||
return; | ||
reloadListModel(); | ||
} | ||
|
||
void Qgs3DViewsManager::set3DMapViewsDom( QMap<QString, QDomElement> &mapViews3DDom ) | ||
{ | ||
m3DMapViewsDom = &mapViews3DDom; | ||
reloadListModel(); | ||
} | ||
|
||
void Qgs3DViewsManager::set3DMapViewsWidgets( QMap<QString, Qgs3DMapCanvasDockWidget *> &mapViews3DWidgets ) | ||
{ | ||
m3DMapViewsWidgets = &mapViews3DWidgets; | ||
} | ||
|
||
void Qgs3DViewsManager::reloadListModel() | ||
{ | ||
mListModel.setStringList( m3DMapViewsDom->keys() ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef QGS3DVIEWSMANAGER_H | ||
#define QGS3DVIEWSMANAGER_H | ||
|
||
#include "ui_qgs3dviewsmanager.h" | ||
|
||
#include <QDialog> | ||
#include <QStringListModel> | ||
#include <QDomElement> | ||
|
||
class Qgs3DMapCanvasDockWidget; | ||
|
||
class Qgs3DViewsManager : public QDialog, private Ui::Qgs3DViewsManager | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit Qgs3DViewsManager( QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); | ||
~Qgs3DViewsManager(); | ||
|
||
void reload(); | ||
|
||
void set3DMapViewsDom( QMap<QString, QDomElement> &mapViews3DDom ); | ||
void set3DMapViewsWidgets( QMap<QString, Qgs3DMapCanvasDockWidget *> &mapViews3DWidgets ); | ||
private: | ||
QStringListModel mListModel; | ||
int mSelectedViewIndex = -1; | ||
|
||
QMap<QString, QDomElement> *m3DMapViewsDom = nullptr; | ||
QMap<QString, Qgs3DMapCanvasDockWidget *> *m3DMapViewsWidgets = nullptr; | ||
|
||
void reloadListModel(); | ||
}; | ||
|
||
#endif // QGS3DVIEWSMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.