summaryrefslogtreecommitdiffstats
path: root/src/kile/kilegrepdialog.h
blob: 1eb1489ea188ee42b782e1cc49740227a5234ad1 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
/* This file is part of the kile project
   Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
   Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
   Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
   Copyright (C) 2003 Jan-Marek Glogowski <glogow@stud.fbi.fh-darmstadt.de>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
   Boston, MA 02110-1301, USA.

   Original from tdebase / kate
*/

#ifndef __KILE_GREP_DIALOG_H_
#define __KILE_GREP_DIALOG_H_

#include <kdialogbase.h>
#include <tqstringlist.h>

#include "kileinfo.h"
#include "latexcmd.h"

class TQCheckBox;
class TQPushButton;
class TQLabel;
class TQEvent;

class KComboBox;
class KLineEdit;
class TDEProcess;
class KURLRequester;
class KListBox;

#define KILEGREP_MAX 12

namespace KileGrep
{
	enum Mode { Project=0, Directory  };
	enum List { SearchItems=0, SearchPaths, SearchTemplates };
	enum TemplateMode { tmNormal=0,tmCommand,tmCommandWithOption,tmEnv,tmGraphics,tmLabel,tmRefs,tmFiles };
}

class KileGrepDialog : public KDialogBase
{
	Q_OBJECT
  

public:
	KileGrepDialog(TQWidget *parent, KileInfo *ki, KileGrep::Mode mode, const char *name = 0);
	~KileGrepDialog();

	void appendFilter(const TQString &name, const TQString &filter);

	void appendTemplate(const TQString &name, const TQString &regexp);
	void clearTemplates();

public slots:
	void slotSearchFor(const TQString &pattern);

signals:
	void itemSelected(const TQString &abs_filename, int line);

private:
	KileInfo *m_ki;
	KileGrep::Mode m_mode;
	TDEProcess *childproc;
	int m_grepJobs;

	void readConfig();
	void writeConfig();

	TQStringList getListItems(KComboBox *combo);
	int findListItem(KComboBox *combo, const TQString &s);
	void updateListItems(KComboBox *combo);

	void processOutput();
	void finish();

	void startGrep();
	bool shouldRestart() { return (m_grepJobs > 0); }
	void clearGrepJobs() { m_grepJobs = 0; }
	TQString buildFilesCommand();
	TQString buildProjectCommand();
	TQString getPattern();
	TQString getShellPattern();
	TQString getCommandList(KileDocument::CmdAttribute attrtype);

	void setupDirectory();
	void setupProject();
	void setDirName(const TQString &dir);
	void setFilter(const TQString &filter);
	TQStringList readList(KileGrep::List listtype);
	void updateLists();
	void updateWidgets();

	TQStringList m_projectfiles;
	TQString m_projectdir;
	bool m_projectOpened;
	
	TQLabel *projectname_label, *projectdirname_label;
	KLineEdit *template_edit;
	KComboBox *filter_combo, *pattern_combo, *template_combo;
	KURLRequester *dir_combo;
	TQCheckBox *recursive_box;
	KListBox *resultbox;
	TQPushButton *search_button, *clear_button, *close_button;
	TQString buf;
	TQString errbuf;
	TQStringList lastSearchPaths;
	TQStringList filter_list;
	TQStringList template_list;
	int m_lastTemplateIndex;

private slots:
	void childExited();
	void receivedOutput(TDEProcess *proc, char *buffer, int buflen);
	void receivedErrOutput(TDEProcess *proc, char *buffer, int buflen);
	void slotItemSelected(const TQString&);
	void slotSearch();
	void slotClear();
	void slotClose();
	void slotFinished();
	void slotPatternTextChanged(const TQString &);
	void slotTemplateActivated(int index);
};

#endif // __KILE_GREP_DIALOG_H_