22 #include <QMessageBox>
33 if ( fi.suffix().compare( QLatin1String(
"qpt" ), Qt::CaseInsensitive ) != 0 )
36 QFile templateFile( file );
37 if ( !templateFile.open( QIODevice::ReadOnly ) )
39 QMessageBox::warning( iface->
view(), tr(
"Load from Template" ), tr(
"Could not read template file." ) );
43 QDomDocument templateDoc;
46 if ( templateDoc.setContent( &templateFile ) )
52 QMessageBox::warning( iface->
view(), tr(
"Load from Template" ), tr(
"Could not read template file." ) );
Abstract base class that may be implemented to handle new types of data to be dropped or pasted in QG...
A common interface for layout designer dialogs and widgets.
virtual QgsLayoutView * view()=0
Returns the layout view utilized by the designer.
virtual QgsLayout * layout()=0
Returns the current layout displayed in the designer.
virtual void selectItems(const QList< QgsLayoutItem * > &items)=0
Selects the specified items.
bool handleFileDrop(QgsLayoutDesignerInterface *iface, QPointF point, const QString &file) override
Called when the specified file has been dropped onto a QGIS layout.
QgsLayoutQptDropHandler(QObject *parent=nullptr)
constructor
QList< QgsLayoutItem * > loadFromTemplate(const QDomDocument &document, const QgsReadWriteContext &context, bool clearExisting=true, bool *ok=nullptr)
Load a layout template document.
static QgsProject * instance()
Returns the QgsProject singleton instance.
The class is used as a container of context for various read/write operations on other objects.
void setPathResolver(const QgsPathResolver &resolver)
Sets up path resolver for conversion between relative and absolute paths.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.