21 #include <QProgressDialog> 22 #include <QDialogButtonBox> 23 #include <QPushButton> 30 : QAbstractItemModel( parent )
39 return createIndex( row, column );
51 return mResults.count();
62 if ( index.row() >= mResults.count() || index.row() < 0 )
75 case Qt::DecorationRole:
106 mResultsModel->deleteLater();
109 mResultsListView->setModel( mResultsModel );
111 connect( mResultsListView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &QgsValidityCheckResultsWidget::selectionChanged );
113 mDescriptionLabel->hide();
118 mDescriptionLabel->setText( description );
119 mDescriptionLabel->setVisible( !description.isEmpty() );
124 std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
125 std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr(
"Running Checks…" ), tr(
"Abort" ), 0, 100, parent );
126 progressDialog->setWindowTitle( title );
132 progressDialog->setValue( static_cast< int >( progress ) );
133 progressDialog->setLabelText( feedback->property(
"progress" ).toString() ) ;
143 while ( QCoreApplication::hasPendingEvents() && ++nIters < 100 )
146 QCoreApplication::processEvents();
150 connect( progressDialog.get(), &QProgressDialog::canceled, progressDialog.get(), [ & ]
161 if ( feedback->isCanceled() )
164 if ( results.empty() )
171 bool hasCritical =
false;
181 QVBoxLayout *l =
new QVBoxLayout();
184 QDialog dlg( parent );
185 dlg.setWindowTitle( title );
187 QDialogButtonBox *buttons =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &dlg );
188 connect( buttons, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
189 connect( buttons, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
192 buttons->button( QDialogButtonBox::Ok )->setEnabled(
false );
193 buttons->button( QDialogButtonBox::Ok )->setToolTip( tr(
"Critical errors prevent this task from proceeding. Please address these issues and then retry." ) );
196 l->addWidget( buttons );
203 void QgsValidityCheckResultsWidget::selectionChanged(
const QModelIndex ¤t,
const QModelIndex & )
206 mDetailedDescriptionTextBrowser->setHtml( desc );
QModelIndex parent(const QModelIndex &child) const override
Represents an individual result from a validity check run by a QgsAbstractValidityCheck subclass...
QString detailedDescription
Detailed description of the result (translated), giving users enough detail for them to resolve the e...
QVariant data(const QModelIndex &index, int role) const override
Warning only, allow operation to proceed but notify user of result.
static QgsValidityCheckRegistry * validityCheckRegistry()
Returns the application's validity check registry, used for managing validity checks.
A QAbstractItemModel subclass for displaying the results from a QgsAbtractValidityCheck.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
void setProxyProgress(double progress)
Sets the progress (from 0 to 100) for the proxied operation.
QModelIndex index(int row, int column, const QModelIndex &parent) const override
QList< QgsValidityCheckResult > runChecks(int type, const QgsValidityCheckContext *context, QgsFeedback *feedback) const
Runs all checks of the specified type and returns a list of results.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling...
Result detailed description.
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &parent) const override
Critical error - notify user of result and prevent operation from proceeding.
Base class for validity check contexts.
A QgsTask shell which proxies progress reports.
void finalize(bool result)
Finalizes the task, with the specified result.
QgsValidityCheckResultsModel(const QList< QgsValidityCheckResult > &results, QObject *parent=nullptr)
Constructor for QgsValidityCheckResultsModel, showing the specified list of checks results...
QString title
A short, translated string summarising the result.