-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
67c6e8f
commit 4c2447f
Showing
6 changed files
with
276 additions
and
0 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,80 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutview.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsLayoutView: QGraphicsView | ||
{ | ||
%Docstring | ||
A graphical widget to display and interact with QgsLayouts. | ||
|
||
QgsLayoutView manages the layout interaction tools and mouse/key events. | ||
|
||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutview.h" | ||
%End | ||
public: | ||
|
||
enum Tool | ||
{ | ||
ToolSelect, | ||
ToolAddItem, | ||
}; | ||
|
||
QgsLayoutView( QWidget *parent /TransferThis/ = 0 ); | ||
%Docstring | ||
Constructor for QgsLayoutView. | ||
%End | ||
|
||
QgsLayout *currentLayout(); | ||
%Docstring | ||
Returns the current layout associated with the view. | ||
.. seealso:: setCurrentLayout() | ||
.. seealso:: layoutSet() | ||
:rtype: QgsLayout | ||
%End | ||
|
||
void setCurrentLayout( QgsLayout *layout /KeepReference/ ); | ||
%Docstring | ||
Sets the current ``layout`` to edit in the view. | ||
.. seealso:: currentLayout() | ||
.. seealso:: layoutSet() | ||
%End | ||
|
||
signals: | ||
|
||
void layoutSet( QgsLayout *layout ); | ||
%Docstring | ||
Emitted when a ``layout`` is set for the view. | ||
.. seealso:: currentLayout() | ||
.. seealso:: setCurrentLayout() | ||
%End | ||
|
||
protected: | ||
virtual void mousePressEvent( QMouseEvent *event ); | ||
|
||
virtual void mouseReleaseEvent( QMouseEvent *event ); | ||
|
||
virtual void mouseMoveEvent( QMouseEvent *event ); | ||
|
||
virtual void mouseDoubleClickEvent( QMouseEvent *event ); | ||
|
||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutview.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
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,47 @@ | ||
import glob | ||
|
||
import re | ||
|
||
#regex = re.compile(r"( *)def defineCharacteristics(self):\n(\s*)self.name, self.i18n_name = self.trAlgorithm\('(.*)'\)\n(\s*)self.group, self.i18n_group = self.trAlgorithm\('(.*)'\)", re.MULTILINE) | ||
|
||
regex = re.compile(r"^(.*)(\s*def name)", re.M | re.DOTALL) | ||
regex2 = re.compile(r"", re.M | re.DOTALL) | ||
regex = re.compile(r"^(.*?)(\s*def name.*)def defineCharacteristics\(self\):\s*\n(.*?)(\s*def .*)$", re.M | re.DOTALL) | ||
#regex = re.compile(r"(\s*)def defineCharacteristics(self):", re.MULTILINE) | ||
|
||
for filename in glob.iglob('./**/*.py', recursive=True): | ||
out = None | ||
with open(filename, 'r') as myfile: | ||
data = myfile.read() | ||
|
||
r = regex.search(data) | ||
if r: | ||
|
||
out = r.groups()[0] | ||
out += '\n\n def __init__(self):\n super().__init__()\n' | ||
out += r.groups()[2] | ||
out += r.groups()[1] | ||
out += r.groups()[3] | ||
print(out) | ||
|
||
#r2=regex2.search(data) | ||
#if r2: | ||
# print(r2.groups()[1]) | ||
# print('-0-----') | ||
# print(r2.groups()[2]) | ||
|
||
#d=regex.sub(r"\1def name(self):\n\2return '\3'\n\n\1def group(self):\n\2return '\5'\n\n\1def defineCharacteristics(self):",data) | ||
#d=regex.sub(r"\1def defineCharacteristics(self)",data) | ||
|
||
if out: | ||
with open(filename, 'w') as myfile: | ||
myfile.write(out) | ||
|
||
if False: | ||
d = r.group() # print(r.groups()) | ||
#print(d) | ||
d = regex.sub(r"\1def name(self):\n\2return '\3'\n\n\1def group(self):\n\2return '\5'\n", d) | ||
print(d) | ||
|
||
# def group(self): | ||
# return '[GDAL] Analysis' d) |
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,58 @@ | ||
/*************************************************************************** | ||
qgslayoutview.cpp | ||
----------------- | ||
Date : July 2017 | ||
Copyright : (C) 2017 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 "qgslayoutview.h" | ||
#include "qgslayout.h" | ||
|
||
QgsLayoutView::QgsLayoutView( QWidget *parent ) | ||
: QGraphicsView( parent ) | ||
{ | ||
|
||
} | ||
|
||
QgsLayout *QgsLayoutView::currentLayout() | ||
{ | ||
return qobject_cast<QgsLayout *>( scene() ); | ||
} | ||
|
||
void QgsLayoutView::setCurrentLayout( QgsLayout *layout ) | ||
{ | ||
setScene( layout ); | ||
|
||
//emit layoutSet, so that designer dialogs can update for the new layout | ||
emit layoutSet( layout ); | ||
} | ||
|
||
void QgsLayoutView::mousePressEvent( QMouseEvent *event ) | ||
{ | ||
QGraphicsView::mousePressEvent( event ); | ||
} | ||
|
||
void QgsLayoutView::mouseReleaseEvent( QMouseEvent *event ) | ||
{ | ||
QGraphicsView::mouseReleaseEvent( event ); | ||
} | ||
|
||
void QgsLayoutView::mouseMoveEvent( QMouseEvent *event ) | ||
{ | ||
QGraphicsView::mouseMoveEvent( event ); | ||
} | ||
|
||
void QgsLayoutView::mouseDoubleClickEvent( QMouseEvent *event ) | ||
{ | ||
QGraphicsView::mouseDoubleClickEvent( event ); | ||
} |
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,87 @@ | ||
/*************************************************************************** | ||
qgslayoutview.h | ||
--------------- | ||
Date : July 2017 | ||
Copyright : (C) 2017 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 QGSLAYOUTVIEW_H | ||
#define QGSLAYOUTVIEW_H | ||
|
||
#include <QGraphicsView> | ||
#include "qgis.h" | ||
#include "qgsprevieweffect.h" // for QgsPreviewEffect::PreviewMode | ||
#include "qgis_gui.h" | ||
|
||
class QgsLayout; | ||
|
||
/** | ||
* \ingroup gui | ||
* A graphical widget to display and interact with QgsLayouts. | ||
* | ||
* QgsLayoutView manages the layout interaction tools and mouse/key events. | ||
* | ||
* \since QGIS 3.0 | ||
*/ | ||
class GUI_EXPORT QgsLayoutView: public QGraphicsView | ||
{ | ||
|
||
Q_OBJECT | ||
|
||
Q_PROPERTY( QgsLayout *currentLayout READ currentLayout WRITE setCurrentLayout NOTIFY layoutSet ) | ||
|
||
public: | ||
|
||
//! Current view tool | ||
enum Tool | ||
{ | ||
ToolSelect = 0, //!< Select/move/resize item tool | ||
ToolAddItem, //!< Add new item tool | ||
}; | ||
|
||
/** | ||
* Constructor for QgsLayoutView. | ||
*/ | ||
QgsLayoutView( QWidget *parent SIP_TRANSFERTHIS = nullptr ); | ||
|
||
/** | ||
* Returns the current layout associated with the view. | ||
* \see setCurrentLayout() | ||
* \see layoutSet() | ||
*/ | ||
QgsLayout *currentLayout(); | ||
|
||
/** | ||
* Sets the current \a layout to edit in the view. | ||
* \see currentLayout() | ||
* \see layoutSet() | ||
*/ | ||
void setCurrentLayout( QgsLayout *layout SIP_KEEPREFERENCE ); | ||
|
||
signals: | ||
|
||
/** | ||
* Emitted when a \a layout is set for the view. | ||
* \see currentLayout() | ||
* \see setCurrentLayout() | ||
*/ | ||
void layoutSet( QgsLayout *layout ); | ||
|
||
protected: | ||
void mousePressEvent( QMouseEvent *event ) override; | ||
void mouseReleaseEvent( QMouseEvent *event ) override; | ||
void mouseMoveEvent( QMouseEvent *event ) override; | ||
void mouseDoubleClickEvent( QMouseEvent *event ) override; | ||
|
||
}; | ||
|
||
#endif // QGSLAYOUTVIEW_H |