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
ea58fd7
commit 45d8918
Showing
5 changed files
with
297 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
python/gui/auto_generated/processing/qgsprocessinghistorywidget.sip.in
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/processing/qgsprocessinghistorywidget.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsProcessingHistoryWidget : QgsPanelWidget | ||
{ | ||
%Docstring(signature="appended") | ||
A widget for showing Processing algorithm exection history. | ||
|
||
.. versionadded:: 3.32 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprocessinghistorywidget.h" | ||
%End | ||
public: | ||
|
||
QgsProcessingHistoryWidget( QWidget *parent /TransferThis/ = 0 ); | ||
%Docstring | ||
Constructor for QgsProcessingHistoryWidget, with the specified ``parent`` widget. | ||
%End | ||
|
||
public slots: | ||
|
||
void clearHistory(); | ||
%Docstring | ||
Clears the Processing history (after user confirmation). | ||
%End | ||
|
||
void openHelp(); | ||
%Docstring | ||
Opens helps for the widget. | ||
%End | ||
|
||
void saveLog(); | ||
%Docstring | ||
Interactively allows users to save the history log. | ||
%End | ||
|
||
}; | ||
|
||
class QgsProcessingHistoryDialog : QDialog | ||
{ | ||
%Docstring(signature="appended") | ||
A dialog for showing Processing algorithm exection history. | ||
|
||
.. warning:: | ||
|
||
This is not part of stable API -- it is exposed to Python for internal use by Processing only! | ||
|
||
.. versionadded:: 3.32 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprocessinghistorywidget.h" | ||
%End | ||
public: | ||
|
||
QgsProcessingHistoryDialog( QWidget *parent /TransferThis/ = 0 ); | ||
%Docstring | ||
Constructor for QgsProcessingHistoryDialog. | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/processing/qgsprocessinghistorywidget.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
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,124 @@ | ||
/*************************************************************************** | ||
qgsprocessinghistorywidget.cpp | ||
------------------------ | ||
Date : April 2023 | ||
Copyright : (C) 2023 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 "qgsprocessinghistorywidget.h" | ||
#include "qgshistorywidget.h" | ||
#include "qgsgui.h" | ||
#include "qgshistoryproviderregistry.h" | ||
#include "qgshistoryprovider.h" | ||
#include "qgshelp.h" | ||
#include "qgsfileutils.h" | ||
#include "qgshistoryentry.h" | ||
|
||
#include <QVBoxLayout> | ||
#include <QMessageBox> | ||
#include <QFileDialog> | ||
#include <QTextStream> | ||
#include <QDialogButtonBox> | ||
#include <QPushButton> | ||
|
||
QgsProcessingHistoryWidget::QgsProcessingHistoryWidget( QWidget *parent ) | ||
: QgsPanelWidget( parent ) | ||
{ | ||
mHistoryWidget = new QgsHistoryWidget( QStringLiteral( "processing" ) ); | ||
QVBoxLayout *vl = new QVBoxLayout(); | ||
vl->setContentsMargins( 0, 0, 0, 0 ); | ||
vl->addWidget( mHistoryWidget ); | ||
|
||
} | ||
|
||
void QgsProcessingHistoryWidget::clearHistory() | ||
{ | ||
if ( QMessageBox::question( this, | ||
tr( "Clear History" ), | ||
tr( "Are you sure you want to clear the Processing history?" ), | ||
QMessageBox::Yes | QMessageBox::No, | ||
QMessageBox::No | ||
) == QMessageBox::Yes ) | ||
{ | ||
QgsGui::historyProviderRegistry()->clearHistory( Qgis::HistoryProviderBackend::LocalProfile, QStringLiteral( "providerId" ) ); | ||
} | ||
} | ||
|
||
void QgsProcessingHistoryWidget::openHelp() | ||
{ | ||
QgsHelp::openHelp( QStringLiteral( "processing/history.html" ) ); | ||
} | ||
|
||
void QgsProcessingHistoryWidget::saveLog() | ||
{ | ||
QString fileName = QFileDialog::getSaveFileName( this, | ||
tr( "Save File" ), | ||
QDir::homePath(), | ||
tr( "Log files (*.log *.LOG)" ) ); | ||
|
||
if ( fileName.isEmpty() ) | ||
return; | ||
|
||
fileName = QgsFileUtils::ensureFileNameHasExtension( fileName, { QStringLiteral( "log" ) } ); | ||
|
||
const QList< QgsHistoryEntry > entries = QgsGui::historyProviderRegistry()->queryEntries( QDateTime(), QDateTime(), QStringLiteral( "processing" ) ); | ||
|
||
const QString logSeparator = QStringLiteral( "|~|" ); | ||
QFile logFile( fileName ); | ||
if ( logFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) | ||
{ | ||
QTextStream logOut( &logFile ); | ||
for ( const QgsHistoryEntry &entry : entries ) | ||
{ | ||
logOut << QStringLiteral( "ALGORITHM{}{}{}{}\n" ).arg( logSeparator, | ||
entry.timestamp.toString( "YYYY-mm-dd HH:MM:SS" ), | ||
logSeparator, | ||
entry.entry.value( QStringLiteral( "python_command" ) ).toString() ); | ||
} | ||
} | ||
} | ||
|
||
|
||
// | ||
// QgsProcessingHistoryDialog | ||
// | ||
|
||
QgsProcessingHistoryDialog::QgsProcessingHistoryDialog( QWidget *parent ) | ||
: QDialog( parent ) | ||
{ | ||
QgsGui::instance()->enableAutoGeometryRestore( this ); | ||
|
||
QVBoxLayout *vl = new QVBoxLayout(); | ||
mWidget = new QgsProcessingHistoryWidget(); | ||
vl->addWidget( mWidget, 1 ); | ||
|
||
mButtonBox = new QDialogButtonBox(); | ||
|
||
QPushButton *clearButton = new QPushButton( tr( "Clear" ) ); | ||
clearButton->setToolTip( tr( "Clear history" ) ); | ||
mButtonBox->addButton( clearButton, QDialogButtonBox::ActionRole ); | ||
|
||
QPushButton *helpButton = new QPushButton( tr( "Help" ) ); | ||
helpButton->setToolTip( tr( "Show help" ) ); | ||
mButtonBox->addButton( helpButton, QDialogButtonBox::HelpRole ); | ||
|
||
QPushButton *saveButton = new QPushButton( tr( "Save As…" ) ); | ||
saveButton->setToolTip( tr( "Save history" ) ); | ||
mButtonBox->addButton( saveButton, QDialogButtonBox::ActionRole ); | ||
|
||
connect( clearButton, &QPushButton::clicked, mWidget, &QgsProcessingHistoryWidget::clearHistory ); | ||
connect( saveButton, &QPushButton::clicked, mWidget, &QgsProcessingHistoryWidget::saveLog ); | ||
connect( helpButton, &QPushButton::clicked, mWidget, &QgsProcessingHistoryWidget::openHelp ); | ||
|
||
vl->addWidget( mButtonBox ); | ||
|
||
setLayout( vl ); | ||
} |
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,90 @@ | ||
/*************************************************************************** | ||
qgsprocessinghistorywidget.h | ||
------------------------ | ||
Date : April 2023 | ||
Copyright : (C) 2023 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 QGSPROCESSINGHISTORYWIDGET_H | ||
#define QGSPROCESSINGHISTORYWIDGET_H | ||
|
||
#include "qgis.h" | ||
#include "qgis_gui.h" | ||
#include "qgspanelwidget.h" | ||
|
||
#include <QDialog> | ||
|
||
class QgsHistoryWidget; | ||
class QDialogButtonBox; | ||
|
||
/** | ||
* \ingroup gui | ||
* \brief A widget for showing Processing algorithm exection history. | ||
* \since QGIS 3.32 | ||
*/ | ||
class GUI_EXPORT QgsProcessingHistoryWidget : public QgsPanelWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
/** | ||
* Constructor for QgsProcessingHistoryWidget, with the specified \a parent widget. | ||
*/ | ||
QgsProcessingHistoryWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr ); | ||
|
||
public slots: | ||
|
||
/** | ||
* Clears the Processing history (after user confirmation). | ||
*/ | ||
void clearHistory(); | ||
|
||
/** | ||
* Opens helps for the widget. | ||
*/ | ||
void openHelp(); | ||
|
||
/** | ||
* Interactively allows users to save the history log. | ||
*/ | ||
void saveLog(); | ||
|
||
private: | ||
|
||
QgsHistoryWidget *mHistoryWidget = nullptr; | ||
|
||
}; | ||
|
||
/** | ||
* \ingroup gui | ||
* \brief A dialog for showing Processing algorithm exection history. | ||
* | ||
* \warning This is not part of stable API -- it is exposed to Python for internal use by Processing only! | ||
* | ||
* \since QGIS 3.32 | ||
*/ | ||
class GUI_EXPORT QgsProcessingHistoryDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
/** | ||
* Constructor for QgsProcessingHistoryDialog. | ||
*/ | ||
QgsProcessingHistoryDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr ); | ||
|
||
private: | ||
|
||
QgsProcessingHistoryWidget *mWidget = nullptr; | ||
QDialogButtonBox *mButtonBox = nullptr; | ||
}; | ||
|
||
#endif // QGSPROCESSINGHISTORYWIDGET_H |