-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrepjob.h
More file actions
125 lines (99 loc) · 3.88 KB
/
grepjob.h
File metadata and controls
125 lines (99 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
* Copyright 1999-2001 by Bernd Gehrmann *
* bernd@kdevelop.org *
* Copyright 2008 by Hamish Rodda *
* rodda@kde.org *
* Copyright 2010 Silvère Lestang <silvere.lestang@gmail.com> *
* Copyright 2010 Julien Desgats <julien.desgats@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef GREPJOB_H
#define GREPJOB_H
#include <QDir>
#include <QPointer>
#include <kurl.h>
#include <kjob.h>
#include <interfaces/istatus.h>
#include "grepfindthread.h"
#include "grepoutputmodel.h"
namespace KDevelop
{
class IProject;
class ProcessLineMaker;
}
class QRegExp;
class GrepViewPlugin;
class FindReplaceTest; //FIXME: this is useful only for tests
class GrepJob : public KJob, public KDevelop::IStatus
{
Q_OBJECT
Q_INTERFACES( KDevelop::IStatus )
friend class GrepViewPlugin;
friend class FindReplaceTest;
private:
///Job can only be instanciated by plugin
GrepJob( QObject *parent = 0 );
public:
void setOutputModel(GrepOutputModel * model);
void setPatternString(const QString& patternString);
void setTemplateString(const QString &templateString);
void setReplacementTemplateString(const QString &replTmplString);
void setFilesString(const QString &filesString);
void setExcludeString(const QString &excludeString);
void setDirectoryChoice(const QList<KUrl> &choice);
void setRecursive(bool recursive);
void setRegexpFlag(bool regexpFlag);
void setCaseSensitive(bool caseSensitive);
void setExcludeComments(bool excludeComments);
void setProjectFilesFlag(bool projectFilesFlag);
virtual void start();
virtual QString statusName() const;
protected:
virtual bool doKill();
// GrepOutputModel* model() const;
private Q_SLOTS:
void slotFindFinished();
void testFinishState(KJob *job);
Q_SIGNALS:
void clearMessage( KDevelop::IStatus* );
void showMessage( KDevelop::IStatus*, const QString & message, int timeout = 0);
void showErrorMessage(const QString & message, int timeout = 0);
void hideProgress( KDevelop::IStatus* );
void showProgress( KDevelop::IStatus*, int minimum, int maximum, int value);
void foundMatches( const QString& filename, const GrepOutputItem::List& matches);
private:
Q_INVOKABLE void slotWork();
QString m_patternString;
QRegExp m_regExp;
QString m_regExpSimple;
GrepOutputModel *m_outputModel;
enum {
WorkCollectFiles,
WorkGrep,
WorkIdle,
WorkCancelled
} m_workState;
KUrl::List m_fileList;
int m_fileIndex;
QPointer<GrepFindFilesThread> m_findThread;
QString m_templateString;
QString m_replacementTemplateString;
QString m_filesString;
QString m_excludeString;
QList<KUrl> m_directoryChoice;
bool m_useProjectFilesFlag;
bool m_regexpFlag;
bool m_recursiveFlag;
bool m_caseSensitiveFlag;
bool m_excludeCommentsFlag;
bool m_findSomething;
};
//FIXME: this function is used externally only for tests, find a way to keep it
// static for a regular compilation
GrepOutputItem::List grepFile(const QString &filename, const QRegExp &re, bool excludeComments);
#endif