Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[geonode] Move GUI related code to new files, remove legacy data item…
…s calls
- Loading branch information
Showing
7 changed files
with
157 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*************************************************************************** | ||
qgsgeonodedataitemguiprovider.cpp | ||
-------------------------------------- | ||
Date : June 2019 | ||
Copyright : (C) 2019 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsgeonodedataitemguiprovider.h" | ||
#include "qgsgeonodedataitems.h" | ||
#include "qgsgeonodenewconnection.h" | ||
|
||
void QgsGeoNodeDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &, QgsDataItemGuiContext ) | ||
{ | ||
if ( QgsGeoNodeRootItem *rootItem = qobject_cast< QgsGeoNodeRootItem * >( item ) ) | ||
{ | ||
QAction *actionNew = new QAction( tr( "New Connection…" ), menu ); | ||
connect( actionNew, &QAction::triggered, this, [rootItem] { newConnection( rootItem ); } ); | ||
menu->addAction( actionNew ); | ||
} | ||
else if ( QgsGeoNodeRootItem *connItem = qobject_cast< QgsGeoNodeRootItem * >( item ) ) | ||
{ | ||
QAction *actionEdit = new QAction( tr( "Edit Connection…" ), menu ); | ||
connect( actionEdit, &QAction::triggered, this, [connItem] { editConnection( connItem ); } ); | ||
menu->addAction( actionEdit ); | ||
|
||
QAction *actionDelete = new QAction( tr( "Delete Connection" ), menu ); | ||
connect( actionDelete, &QAction::triggered, this, [connItem] { deleteConnection( connItem ); } ); | ||
menu->addAction( actionDelete ); | ||
} | ||
} | ||
|
||
void QgsGeoNodeDataItemGuiProvider::newConnection( QgsDataItem *item ) | ||
{ | ||
QgsGeoNodeNewConnection nc( nullptr ); | ||
|
||
if ( nc.exec() ) | ||
{ | ||
item->refresh(); | ||
} | ||
} | ||
|
||
void QgsGeoNodeDataItemGuiProvider::editConnection( QgsDataItem *item ) | ||
{ | ||
QgsGeoNodeNewConnection nc( nullptr, item->name() ); | ||
nc.setWindowTitle( tr( "Modify GeoNode connection" ) ); | ||
|
||
if ( nc.exec() ) | ||
{ | ||
// the parent should be updated | ||
item->parent()->refresh(); | ||
} | ||
} | ||
|
||
void QgsGeoNodeDataItemGuiProvider::deleteConnection( QgsDataItem *item ) | ||
{ | ||
QgsGeoNodeConnectionUtils::deleteConnection( item->name() ); | ||
item->parent()->refresh(); | ||
} |
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,37 @@ | ||
/*************************************************************************** | ||
qgsgeonodedataitemguiprovider.h | ||
-------------------------------------- | ||
Date : June 2019 | ||
Copyright : (C) 2019 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSGEONODEDATAITEMGUIPROVIDER_H | ||
#define QGSGEONODEDATAITEMGUIPROVIDER_H | ||
|
||
#include "qgsdataitemguiprovider.h" | ||
|
||
class QgsGeoNodeDataItemGuiProvider : public QObject, public QgsDataItemGuiProvider | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
QString name() override { return QStringLiteral( "GeoNode" ); } | ||
|
||
void populateContextMenu( QgsDataItem *item, QMenu *menu, | ||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override; | ||
|
||
private: | ||
static void newConnection( QgsDataItem *item ); | ||
static void editConnection( QgsDataItem *item ); | ||
static void deleteConnection( QgsDataItem *item ); | ||
}; | ||
|
||
#endif // QGSGEONODEDATAITEMGUIPROVIDER_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
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,51 @@ | ||
/*************************************************************************** | ||
qgsgeonodeprovidergui.cpp | ||
-------------------------------------- | ||
Date : June 2019 | ||
Copyright : (C) 2019 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsproviderguimetadata.h" | ||
|
||
#include "qgsgeonodedataitemguiprovider.h" | ||
#include "qgsgeonodesourceselect.h" | ||
|
||
static const QString PROVIDER_KEY = QStringLiteral( "geonode" ); | ||
|
||
|
||
class QgsGeonodeProviderGuiMetadata: public QgsProviderGuiMetadata | ||
{ | ||
public: | ||
QgsGeonodeProviderGuiMetadata() | ||
: QgsProviderGuiMetadata( PROVIDER_KEY ) | ||
{ | ||
} | ||
|
||
QList<QgsDataItemGuiProvider *> dataItemGuiProviders() override | ||
{ | ||
QList<QgsDataItemGuiProvider *> providers; | ||
providers << new QgsGeoNodeDataItemGuiProvider; | ||
return providers; | ||
} | ||
|
||
QList<QgsSourceSelectProvider *> sourceSelectProviders() override | ||
{ | ||
QList<QgsSourceSelectProvider *> providers; | ||
providers << new QgsGeoNodeSourceSelectProvider; | ||
return providers; | ||
} | ||
}; | ||
|
||
|
||
QGISEXTERN QgsProviderGuiMetadata *providerGuiMetadataFactory() | ||
{ | ||
return new QgsGeonodeProviderGuiMetadata(); | ||
} |