-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5221 from nyalldawson/browser_awesome
Add QLR, processing models to browser
- Loading branch information
Showing
11 changed files
with
277 additions
and
21 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
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,80 @@ | ||
/*************************************************************************** | ||
qgsappbrowserproviders.cpp | ||
--------------------------- | ||
begin : September 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson 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 "qgsappbrowserproviders.h" | ||
#include "qgisapp.h" | ||
|
||
// | ||
// QgsQlrDataItem | ||
// | ||
|
||
QgsQlrDataItem::QgsQlrDataItem( QgsDataItem *parent, const QString &name, const QString &path ) | ||
: QgsLayerItem( parent, name, path, path, QgsLayerItem::NoType, QStringLiteral( "qlr" ) ) | ||
{ | ||
setState( QgsDataItem::Populated ); // no children | ||
setIconName( QStringLiteral( ":/images/icons/qgis-icon-16x16.png" ) ); | ||
setToolTip( QDir::toNativeSeparators( path ) ); | ||
} | ||
|
||
bool QgsQlrDataItem::hasDragEnabled() const | ||
{ | ||
return true; | ||
} | ||
|
||
QgsMimeDataUtils::Uri QgsQlrDataItem::mimeUri() const | ||
{ | ||
QgsMimeDataUtils::Uri u; | ||
u.layerType = QStringLiteral( "custom" ); | ||
u.providerKey = QStringLiteral( "qlr" ); | ||
u.name = name(); | ||
u.uri = path(); | ||
return u; | ||
} | ||
|
||
// | ||
// QgsQlrDataItemProvider | ||
// | ||
|
||
QString QgsQlrDataItemProvider::name() | ||
{ | ||
return QStringLiteral( "QLR" ); | ||
} | ||
|
||
int QgsQlrDataItemProvider::capabilities() | ||
{ | ||
return QgsDataProvider::File; | ||
} | ||
|
||
QgsDataItem *QgsQlrDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem ) | ||
{ | ||
QFileInfo fileInfo( path ); | ||
|
||
if ( fileInfo.suffix().compare( QStringLiteral( "qlr" ), Qt::CaseInsensitive ) == 0 ) | ||
{ | ||
return new QgsQlrDataItem( parentItem, fileInfo.fileName(), path ); | ||
} | ||
return nullptr; | ||
} | ||
|
||
QString QgsQlrDropHandler::customUriProviderKey() const | ||
{ | ||
return QStringLiteral( "qlr" ); | ||
} | ||
|
||
void QgsQlrDropHandler::handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) const | ||
{ | ||
QString path = uri.uri; | ||
QgisApp::instance()->openLayerDefinition( path ); | ||
} |
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,50 @@ | ||
/*************************************************************************** | ||
qgsappbrowserproviders.h | ||
------------------------- | ||
begin : September 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson 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 QGSAPPBROWSERPROVIDERS_H | ||
#define QGSAPPBROWSERPROVIDERS_H | ||
|
||
#include "qgsdataitemprovider.h" | ||
#include "qgsdataprovider.h" | ||
#include "qgscustomdrophandler.h" | ||
|
||
class QgsQlrDataItem : public QgsLayerItem | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
QgsQlrDataItem( QgsDataItem *parent, const QString &name, const QString &path ); | ||
bool hasDragEnabled() const override; | ||
QgsMimeDataUtils::Uri mimeUri() const override; | ||
|
||
}; | ||
|
||
class QgsQlrDataItemProvider : public QgsDataItemProvider | ||
{ | ||
public: | ||
QString name() override; | ||
int capabilities() override; | ||
QgsDataItem *createDataItem( const QString &path, QgsDataItem *parentItem ) override; | ||
}; | ||
|
||
class QgsQlrDropHandler : public QgsCustomDropHandler | ||
{ | ||
public: | ||
|
||
QString customUriProviderKey() const override; | ||
void handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) const override; | ||
}; | ||
|
||
#endif // QGSAPPBROWSERPROVIDERS_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
Oops, something went wrong.