Changeset View
Changeset View
Standalone View
Standalone View
plugins/grepview/grepjob.cpp
Context not available. | |||||
90 | : KJob( parent ) | 90 | : KJob( parent ) | ||
---|---|---|---|---|---|
91 | , m_workState(WorkIdle) | 91 | , m_workState(WorkIdle) | ||
92 | , m_fileIndex(0) | 92 | , m_fileIndex(0) | ||
93 | , m_useProjectFilesFlag(false) | | |||
94 | , m_regexpFlag(true) | | |||
95 | , m_caseSensitiveFlag(true) | | |||
96 | , m_depthValue(-1) | | |||
97 | , m_findSomething(false) | 93 | , m_findSomething(false) | ||
98 | { | 94 | { | ||
99 | setCapabilities(Killable); | 95 | setCapabilities(Killable); | ||
Context not available. | |||||
134 | return; | 130 | return; | ||
135 | } | 131 | } | ||
136 | 132 | | |||
137 | if(!m_regexpFlag) | 133 | if(!m_settings.regexp) | ||
138 | { | 134 | { | ||
139 | m_patternString = QRegExp::escape(m_patternString); | 135 | m_settings.pattern = QRegExp::escape(m_settings.pattern); | ||
140 | } | 136 | } | ||
141 | 137 | | |||
142 | if(m_regexpFlag && QRegExp(m_patternString).captureCount() > 0) | 138 | if(m_settings.regexp && QRegExp(m_settings.pattern).captureCount() > 0) | ||
143 | { | 139 | { | ||
144 | m_workState = WorkIdle; | 140 | m_workState = WorkIdle; | ||
145 | emit hideProgress(this); | 141 | emit hideProgress(this); | ||
Context not available. | |||||
151 | return; | 147 | return; | ||
152 | } | 148 | } | ||
153 | 149 | | |||
154 | QString pattern = substitudePattern(m_templateString, m_patternString); | 150 | QString pattern = substitudePattern(m_settings.searchTemplate, m_settings.pattern); | ||
155 | m_regExp.setPattern(pattern); | 151 | m_regExp.setPattern(pattern); | ||
156 | m_regExp.setPatternSyntax(QRegExp::RegExp2); | 152 | m_regExp.setPatternSyntax(QRegExp::RegExp2); | ||
157 | m_regExp.setCaseSensitivity( m_caseSensitiveFlag ? Qt::CaseSensitive : Qt::CaseInsensitive ); | 153 | m_regExp.setCaseSensitivity( m_settings.caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive ); | ||
158 | if(pattern == QRegExp::escape(pattern)) | 154 | if(pattern == QRegExp::escape(pattern)) | ||
159 | { | 155 | { | ||
160 | // enable wildcard mode when possible | 156 | // enable wildcard mode when possible | ||
Context not available. | |||||
163 | } | 159 | } | ||
164 | 160 | | |||
165 | m_outputModel->setRegExp(m_regExp); | 161 | m_outputModel->setRegExp(m_regExp); | ||
166 | m_outputModel->setReplacementTemplate(m_replacementTemplateString); | 162 | m_outputModel->setReplacementTemplate(m_settings.replacementTemplate); | ||
167 | 163 | | |||
168 | 164 | | |||
169 | emit showMessage(this, i18np("Searching for <b>%2</b> in one file", | 165 | emit showMessage(this, i18np("Searching for <b>%2</b> in one file", | ||
Context not available. | |||||
186 | QMetaObject::invokeMethod(this, "slotWork", Qt::QueuedConnection); | 182 | QMetaObject::invokeMethod(this, "slotWork", Qt::QueuedConnection); | ||
187 | break; | 183 | break; | ||
188 | case WorkCollectFiles: | 184 | case WorkCollectFiles: | ||
189 | m_findThread = new GrepFindFilesThread(this, m_directoryChoice, m_depthValue, m_filesString, m_excludeString, m_useProjectFilesFlag); | 185 | m_findThread = new GrepFindFilesThread(this, m_directoryChoice, m_settings.depth, m_settings.files, m_settings.exclude, m_settings.projectFilesOnly); | ||
190 | emit showMessage(this, i18n("Collecting files...")); | 186 | emit showMessage(this, i18n("Collecting files...")); | ||
191 | connect(m_findThread.data(), &GrepFindFilesThread::finished, this, &GrepJob::slotFindFinished); | 187 | connect(m_findThread.data(), &GrepFindFilesThread::finished, this, &GrepJob::slotFindFinished); | ||
192 | m_findThread->start(); | 188 | m_findThread->start(); | ||
Context not available. | |||||
279 | m_outputModel = model; | 275 | m_outputModel = model; | ||
280 | } | 276 | } | ||
281 | 277 | | |||
282 | void GrepJob::setTemplateString(const QString& templateString) | | |||
283 | { | | |||
284 | m_templateString = templateString; | | |||
285 | } | | |||
286 | | ||||
287 | void GrepJob::setReplacementTemplateString(const QString &replTmplString) | | |||
288 | { | | |||
289 | m_replacementTemplateString = replTmplString; | | |||
290 | } | | |||
291 | | ||||
292 | void GrepJob::setFilesString(const QString& filesString) | | |||
293 | { | | |||
294 | m_filesString = filesString; | | |||
295 | } | | |||
296 | | ||||
297 | void GrepJob::setExcludeString(const QString& excludeString) | | |||
298 | { | | |||
299 | m_excludeString = excludeString; | | |||
300 | } | | |||
301 | | ||||
302 | void GrepJob::setDirectoryChoice(const QList<QUrl>& choice) | 278 | void GrepJob::setDirectoryChoice(const QList<QUrl>& choice) | ||
303 | { | 279 | { | ||
304 | m_directoryChoice = choice; | 280 | m_directoryChoice = choice; | ||
305 | } | 281 | } | ||
306 | 282 | | |||
307 | void GrepJob::setCaseSensitive(bool caseSensitive) | 283 | void GrepJob::setSettings(const GrepJobSettings& settings) | ||
308 | { | | |||
309 | m_caseSensitiveFlag = caseSensitive; | | |||
310 | } | | |||
311 | | ||||
312 | void GrepJob::setDepth(int depth) | | |||
313 | { | 284 | { | ||
314 | m_depthValue = depth; | 285 | m_settings = settings; | ||
315 | } | | |||
316 | 286 | | |||
317 | void GrepJob::setRegexpFlag(bool regexpFlag) | 287 | setObjectName(i18n("Grep: %1", m_settings.pattern)); | ||
318 | { | | |||
319 | m_regexpFlag = regexpFlag; | | |||
320 | } | 288 | } | ||
321 | 289 | | |||
322 | void GrepJob::setProjectFilesFlag(bool projectFilesFlag) | 290 | GrepJobSettings GrepJob::settings() const | ||
323 | { | 291 | { | ||
324 | m_useProjectFilesFlag = projectFilesFlag; | 292 | return m_settings; | ||
325 | } | 293 | } | ||
326 | | ||||
327 | void GrepJob::setPatternString(const QString& patternString) | | |||
328 | { | | |||
329 | m_patternString = patternString; | | |||
330 | | ||||
331 | setObjectName(i18n("Grep: %1", m_patternString)); | | |||
332 | } | | |||
333 | | ||||
Context not available. |