23#include <QDialogButtonBox>
24#include <QProgressDialog>
28#include "moc_qgsvaliditycheckresultswidget.cpp"
30using namespace Qt::StringLiterals;
37 : QAbstractItemModel(
parent )
45 return createIndex( row, column );
57 return mResults.count();
68 if (
index.row() >= mResults.count() ||
index.row() < 0 )
81 case Qt::DecorationRole:
111 mResultsModel->deleteLater();
114 mResultsListView->setModel( mResultsModel );
116 connect( mResultsListView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &QgsValidityCheckResultsWidget::selectionChanged );
118 if ( mResultsModel->rowCount() > 0 )
121 const QModelIndex firstResult( mResultsModel->index( 0, 0, QModelIndex() ) );
122 mResultsListView->selectionModel()->select( firstResult, QItemSelectionModel::ClearAndSelect );
123 selectionChanged( firstResult, QModelIndex() );
126 mDescriptionLabel->hide();
131 mDescriptionLabel->setText( description );
132 mDescriptionLabel->setVisible( !description.isEmpty() );
137 auto feedback = std::make_unique<QgsFeedback>();
138 auto progressDialog = std::make_unique<QProgressDialog>( tr(
"Running Checks…" ), tr(
"Abort" ), 0, 100, parent );
139 progressDialog->setWindowTitle( title );
144 progressDialog->setValue( static_cast<int>( progress ) );
145 progressDialog->setLabelText( feedback->property(
"progress" ).toString() );
147 proxyTask->setProxyProgress( progress );
153 while ( ++nIters < 100 )
156 QCoreApplication::processEvents();
159 connect( progressDialog.get(), &QProgressDialog::canceled, progressDialog.get(), [&] {
167 proxyTask->finalize(
true );
169 if ( feedback->isCanceled() )
172 if ( results.empty() )
179 bool hasCritical =
false;
189 QVBoxLayout *l =
new QVBoxLayout();
192 QDialog dlg( parent );
193 dlg.setWindowTitle( title );
195 QDialogButtonBox *buttons =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &dlg );
196 connect( buttons, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
197 connect( buttons, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
200 buttons->button( QDialogButtonBox::Ok )->setEnabled(
false );
201 buttons->button( QDialogButtonBox::Ok )->setToolTip( tr(
"Critical errors prevent this task from proceeding. Please address these issues and then retry." ) );
204 l->addWidget( buttons );
211void QgsValidityCheckResultsWidget::selectionChanged(
const QModelIndex ¤t,
const QModelIndex & )
214 mDetailedDescriptionTextBrowser->setHtml( desc );
static QgsValidityCheckRegistry * validityCheckRegistry()
Returns the application's validity check registry, used for managing validity checks.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
A QgsTask shell which proxies progress reports.
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager.
Base class for validity check contexts.
QList< QgsValidityCheckResult > runChecks(int type, const QgsValidityCheckContext *context, QgsFeedback *feedback) const
Runs all checks of the specified type and returns a list of results.
Represents an individual result from a validity check run by a QgsAbstractValidityCheck subclass.
QgsValidityCheckResult::Type type
Result type.
@ Critical
Critical error - notify user of result and prevent operation from proceeding.
@ Warning
Warning only, allow operation to proceed but notify user of result.
QString detailedDescription
Detailed description of the result (translated), giving users enough detail for them to resolve the e...
QString title
A short, translated string summarising the result.
A QAbstractItemModel subclass for displaying the results from a QgsAbstractValidityCheck.
QgsValidityCheckResultsModel(const QList< QgsValidityCheckResult > &results, QObject *parent=nullptr)
Constructor for QgsValidityCheckResultsModel, showing the specified list of checks results.
QModelIndex parent(const QModelIndex &child) const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
@ Description
Result detailed description.
int columnCount(const QModelIndex &parent) const override
QVariant data(const QModelIndex &index, int role) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override