Changeset View
Changeset View
Standalone View
Standalone View
outputview/outputexecutejob.cpp
Show All 34 Lines | |||||
35 | class OutputExecuteJobPrivate | 35 | class OutputExecuteJobPrivate | ||
36 | { | 36 | { | ||
37 | public: | 37 | public: | ||
38 | OutputExecuteJobPrivate( KDevelop::OutputExecuteJob* owner ); | 38 | OutputExecuteJobPrivate( KDevelop::OutputExecuteJob* owner ); | ||
39 | 39 | | |||
40 | void childProcessStdout(); | 40 | void childProcessStdout(); | ||
41 | void childProcessStderr(); | 41 | void childProcessStderr(); | ||
42 | 42 | | |||
43 | void emitProgress(const IFilterStrategy::Progress& progress); | ||||
mwolff: cref | |||||
44 | | ||||
43 | QString joinCommandLine() const; | 45 | QString joinCommandLine() const; | ||
44 | QString getJobName(); | 46 | QString getJobName(); | ||
45 | 47 | | |||
46 | template< typename T > | 48 | template< typename T > | ||
47 | static void mergeEnvironment( QProcessEnvironment& dest, const T& src ); | 49 | static void mergeEnvironment( QProcessEnvironment& dest, const T& src ); | ||
48 | QProcessEnvironment effectiveEnvironment() const; | 50 | QProcessEnvironment effectiveEnvironment() const; | ||
49 | QStringList effectiveCommandLine() const; | 51 | QStringList effectiveCommandLine() const; | ||
50 | 52 | | |||
51 | OutputExecuteJob* m_owner; | 53 | OutputExecuteJob* m_owner; | ||
52 | 54 | | |||
53 | KProcess* m_process; | 55 | KProcess* m_process; | ||
54 | ProcessLineMaker* m_lineMaker; | 56 | ProcessLineMaker* m_lineMaker; | ||
55 | OutputExecuteJob::JobStatus m_status; | 57 | OutputExecuteJob::JobStatus m_status; | ||
56 | OutputExecuteJob::JobProperties m_properties; | 58 | OutputExecuteJob::JobProperties m_properties; | ||
57 | OutputModel::OutputFilterStrategy m_filteringStrategy; | 59 | OutputModel::OutputFilterStrategy m_filteringStrategy; | ||
60 | QScopedPointer<IFilterStrategy> m_filteringStrategyPtr; | ||||
58 | QStringList m_arguments; | 61 | QStringList m_arguments; | ||
59 | QStringList m_privilegedExecutionCommand; | 62 | QStringList m_privilegedExecutionCommand; | ||
60 | QUrl m_workingDirectory; | 63 | QUrl m_workingDirectory; | ||
61 | QString m_environmentProfile; | 64 | QString m_environmentProfile; | ||
62 | QHash<QString, QString> m_environmentOverrides; | 65 | QHash<QString, QString> m_environmentOverrides; | ||
63 | QString m_jobName; | 66 | QString m_jobName; | ||
64 | bool m_outputStarted; | 67 | bool m_outputStarted; | ||
65 | }; | 68 | }; | ||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Line(s) | 212 | if( !successfullyCreated ) { | |||
216 | return emitResult(); | 219 | return emitResult(); | ||
217 | } | 220 | } | ||
218 | } | 221 | } | ||
219 | 222 | | |||
220 | setModel( new OutputModel( effectiveWorkingDirectory ) ); | 223 | setModel( new OutputModel( effectiveWorkingDirectory ) ); | ||
221 | } | 224 | } | ||
222 | Q_ASSERT( model() ); | 225 | Q_ASSERT( model() ); | ||
223 | 226 | | |||
227 | if (d->m_filteringStrategy != OutputModel::NoFilter) { | ||||
224 | model()->setFilteringStrategy( d->m_filteringStrategy ); | 228 | model()->setFilteringStrategy(d->m_filteringStrategy); | ||
229 | } else { | ||||
230 | model()->setFilteringStrategy(d->m_filteringStrategyPtr.take()); | ||||
231 | } | ||||
232 | | ||||
225 | setDelegate( new OutputDelegate ); | 233 | setDelegate( new OutputDelegate ); | ||
226 | 234 | | |||
235 | connect(model(), &OutputModel::progress, this, [&](const IFilterStrategy::Progress& progress) { | ||||
236 | d->emitProgress(progress); | ||||
237 | }); | ||||
238 | | ||||
227 | // Slots hasRawStdout() and hasRawStderr() are responsible | 239 | // Slots hasRawStdout() and hasRawStderr() are responsible | ||
228 | // for feeding raw data to the line maker; so property-based channel filtering is implemented there. | 240 | // for feeding raw data to the line maker; so property-based channel filtering is implemented there. | ||
229 | if( d->m_properties.testFlag( PostProcessOutput ) ) { | 241 | if( d->m_properties.testFlag( PostProcessOutput ) ) { | ||
230 | connect( d->m_lineMaker, &ProcessLineMaker::receivedStdoutLines, | 242 | connect( d->m_lineMaker, &ProcessLineMaker::receivedStdoutLines, | ||
231 | this, &OutputExecuteJob::postProcessStdout ); | 243 | this, &OutputExecuteJob::postProcessStdout ); | ||
232 | connect( d->m_lineMaker, &ProcessLineMaker::receivedStderrLines, | 244 | connect( d->m_lineMaker, &ProcessLineMaker::receivedStderrLines, | ||
233 | this, &OutputExecuteJob::postProcessStderr ); | 245 | this, &OutputExecuteJob::postProcessStderr ); | ||
234 | } else { | 246 | } else { | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | |||||
363 | void OutputExecuteJobPrivate::childProcessStderr() | 375 | void OutputExecuteJobPrivate::childProcessStderr() | ||
364 | { | 376 | { | ||
365 | QByteArray err = m_process->readAllStandardError(); | 377 | QByteArray err = m_process->readAllStandardError(); | ||
366 | if( m_properties.testFlag( OutputExecuteJob::DisplayStderr ) ) { | 378 | if( m_properties.testFlag( OutputExecuteJob::DisplayStderr ) ) { | ||
367 | m_lineMaker->slotReceivedStderr( err ); | 379 | m_lineMaker->slotReceivedStderr( err ); | ||
368 | } | 380 | } | ||
369 | } | 381 | } | ||
370 | 382 | | |||
383 | void OutputExecuteJobPrivate::emitProgress(const IFilterStrategy::Progress& progress) | ||||
384 | { | ||||
385 | m_owner->emitPercent(progress.percent, 100); | ||||
386 | | ||||
387 | if (progress.percent == 100) { | ||||
388 | m_owner->infoMessage(m_owner, i18n("Build finished")); | ||||
389 | } else { | ||||
390 | m_owner->infoMessage(m_owner, progress.status); | ||||
391 | } | ||||
392 | } | ||||
393 | | ||||
371 | void OutputExecuteJob::postProcessStdout( const QStringList& lines ) | 394 | void OutputExecuteJob::postProcessStdout( const QStringList& lines ) | ||
372 | { | 395 | { | ||
373 | model()->appendLines( lines ); | 396 | model()->appendLines( lines ); | ||
374 | } | 397 | } | ||
375 | 398 | | |||
376 | void OutputExecuteJob::postProcessStderr( const QStringList& lines ) | 399 | void OutputExecuteJob::postProcessStderr( const QStringList& lines ) | ||
377 | { | 400 | { | ||
378 | model()->appendLines( lines ); | 401 | model()->appendLines( lines ); | ||
379 | } | 402 | } | ||
380 | 403 | | |||
381 | void OutputExecuteJob::setFilteringStrategy( OutputModel::OutputFilterStrategy strategy ) | 404 | void OutputExecuteJob::setFilteringStrategy( OutputModel::OutputFilterStrategy strategy ) | ||
382 | { | 405 | { | ||
383 | d->m_filteringStrategy = strategy; | 406 | d->m_filteringStrategy = strategy; | ||
407 | | ||||
408 | // clear the other | ||||
409 | d->m_filteringStrategyPtr.reset(nullptr); | ||||
mwolff: scoped ptr + reset? | |||||
410 | } | ||||
411 | | ||||
412 | void OutputExecuteJob::setFilteringStrategy(IFilterStrategy* filterStrategy) | ||||
413 | { | ||||
414 | d->m_filteringStrategyPtr.reset(filterStrategy); | ||||
415 | | ||||
416 | // clear the other | ||||
417 | d->m_filteringStrategy = OutputModel::NoFilter; | ||||
384 | } | 418 | } | ||
385 | 419 | | |||
386 | OutputExecuteJob::JobProperties OutputExecuteJob::properties() const | 420 | OutputExecuteJob::JobProperties OutputExecuteJob::properties() const | ||
387 | { | 421 | { | ||
388 | return d->m_properties; | 422 | return d->m_properties; | ||
389 | } | 423 | } | ||
390 | 424 | | |||
391 | void OutputExecuteJob::setProperties( OutputExecuteJob::JobProperties properties, bool override ) | 425 | void OutputExecuteJob::setProperties( OutputExecuteJob::JobProperties properties, bool override ) | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
cref