| 48 | } |
| 49 | |
| 50 | void SourceFormatterJob::doWork() |
| 51 | { |
| 52 | // TODO: consider to use ExecuteCompositeJob, with every file a separate subjob |
| 53 | switch (m_workState) { |
| 54 | case WorkIdle: |
| 55 | m_workState = WorkFormat; |
| 56 | m_fileIndex = 0; |
| 57 | emit showProgress(this, 0, 0, 0); |
| 58 | emit showMessage(this, i18np("Reformatting one file", |
| 59 | "Reformatting %1 files", |
| 60 | m_fileList.length())); |
| 61 | |
| 62 | QMetaObject::invokeMethod(this, "doWork", Qt::QueuedConnection); |
| 63 | break; |
| 64 | case WorkFormat: |
| 65 | if (m_fileIndex < m_fileList.length()) { |
| 66 | emit showProgress(this, 0, m_fileList.length(), m_fileIndex); |
| 67 | formatFile(m_fileList[m_fileIndex]); |
| 68 | |
| 69 | // trigger formatting of next file |
| 70 | ++m_fileIndex; |
| 71 | QMetaObject::invokeMethod(this, "doWork", Qt::QueuedConnection); |
| 72 | } else { |
| 73 | m_workState = WorkIdle; |
| 74 | emitResult(); |
| 75 | } |
| 76 | break; |
| 77 | case WorkCancelled: |
| 78 | break; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void SourceFormatterJob::start() |
| 83 | { |