summaryrefslogtreecommitdiffstats
path: root/src/kscope.h
blob: f657493fbd8e310815e88fa1b9f0f43b22b35da4 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/***************************************************************************
 *
 * Copyright (C) 2005 Elad Lahav (elad_lahav@users.sourceforge.net)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 ***************************************************************************/

#ifndef KSCOPE_H
#define KSCOPE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tqtimer.h>
#include <tdecmdlineargs.h>
#include <kapp.h>
#include <tdeparts/dockmainwindow.h>
#include <tdeparts/part.h>

class ProjectManager;
class EditorTabs;
class FileView;
class FileList;
class QueryWidget;
class EditorManager;
class CscopeFrontend;
class EditorPage;
class ProgressDlg;
class CscopeMsgDlg;
class MakeDlg;
class CallTreeManager;
class KScopeActions;

/**
 * Defines the main window of KScope.
 * The main window has both UI and functional tasks. As a window, it is
 * composed of three parts:
 * 1. The editing area (EditorTabs - a tab widget with editor pages)
 * 2. The project pane (FileList - listing the files in the project)
 * 3. The query pane (QueryWidget - a tab widget with pages displaying query
 *    results in lists)
 * The main window also maintains the main menu, the toolbar and the status-
 * bar, and is responsible for handling all the actions connected to these
 * bars.
 * As the application's main class, it is responsible for managing projects
 * (using a ProjectManager object) and for running instances of Cscope
 * (through a CscopeFrontend object).
 * @author Elad Lahav
 */
class KScope : public KParts::DockMainWindow
{
	Q_OBJECT

public:
	KScope(TQWidget* pParent = 0, const char* szName = 0);
	~KScope();

	void openProject(const TQString&);
	void openLastProject();
	bool openCscopeOut(const TQString&);
	void parseCmdLine(TDECmdLineArgs *pArgs);
	void verifyCscope();
	
public slots:
	void slotClose();

protected:
	virtual bool queryClose();
	
private:
	/** A project manager used to load projects and read their properties. */
	ProjectManager* m_pProjMgr;
	
	/** The editors tabbed window. */
	EditorTabs* m_pEditTabs;
	
	/** The file selection widget (project file list and OS file system
		tree.) */
	FileView* m_pFileView;
	
	/** Pointer to the file list part of the FileView widget. */
	FileList* m_pFileList;
	
	/** The query results tabbed window. */
	QueryWidget* m_pQueryWidget;
	
	/** A TDE editor part manager, responsible for creating KTextEditor
		parts. */
	EditorManager* m_pEditMgr;
	
	/** A Cscope process for building the database. */
	CscopeFrontend* m_pCscopeBuild;

	/** A timer for rebuilding the database after a file has been saved. */
	TQTimer m_timerRebuild;
	
	/** Whether the query window should be hidden after the user selects an
		item. */	
	bool m_bHideQueryOnSelection;
	
	/** The file view docking area. */
	KDockWidget* m_pFileViewDock;
	
	/** The query window docking area. */
	KDockWidget* m_pQueryDock;

	/** A persistent dialog used to display error messages from Cscope. */
	CscopeMsgDlg* m_pMsgDlg;
	
	/** The path of the file currently being edited. */
	TQString m_sCurFilePath;
	
	/** The line number of the current cursor position. */
	int m_nCurLine;
	
	/** Creates and maintains call tree dialogues. */
	CallTreeManager* m_pCallTreeMgr;
	
	/** A progress dialogue that is displayed when building the database for
		the first time. */
	ProgressDlg* m_pProgressDlg;
	
	/** A flag indicating whether the GUI of the embedded editor should be
		merged with that of KScope's. Can be turned off to save time when
		loading/closing a number of editor parts. */
	bool m_bUpdateGUI;
	
	/** Set to true after a shell script has verified that Cscope is installed
		and correctly configured on this system.
		No Cscope operations should be run if this flag is set to false. */
	bool m_bCscopeVerified;
	
	/**
	 * Used to postpone rebuilding of the database, until Cscope is ready.
	 */
	bool m_bRebuildDB;
	
	/**
	 * A widget for running make.
	 */
	MakeDlg* m_pMakeDlg;
	
	/**
	 * Manages menu and tool-bar commands.
	 */
	KScopeActions* m_pActions;
	
	void initMainWindow();
	void initCscope();
	bool getSymbol(uint&, TQString&, bool&, bool bPrompt = true);
	EditorPage* addEditor(const TQString&s);
	EditorPage* createEditorPage();
	inline bool isAutoRebuildEnabled();
	void restoreSession();
	void toggleQueryWindow(bool);
	
	friend class KScopeActions;
	
private slots:
	// Menu actions
	void slotNewFile();
	void slotOpenFile();
	void slotCloseEditor();
	void slotCreateProject();
	void slotOpenProject();
	void slotProjectFiles();
	void slotProjectProps();
	void slotProjectCscopeOut();
	bool slotCloseProject();
	void slotQueryReference();
	void slotQueryDefinition();
	void slotQueryCalled();
	void slotQueryCalling();
	void slotQueryText();
	void slotQueryPattern();
	void slotQueryFile();
	void slotQueryIncluding();
	void slotQueryQuickDef();
	void slotCallTree();
	void slotRebuildDB();
	void slotHistoryShow();
	void slotShortcuts();
	void slotConfigure();
	void slotCloseAllWindows();
	void slotExtEdit();
	void slotCompleteSymbol();
	void slotShowWelcome();
	void slotGotoTag();
	void slotProjectMake();
	void slotProjectRemake();
	void slotShowBookmarks();
	
	// Other slots
	void slotProjectFilesChanged();
	void slotFilesAdded(const TQStringList&);
	void slotQuery(uint, bool);
	void slotDeleteEditor(EditorPage*);
	void slotChangeEditor(EditorPage*, EditorPage*);
	void slotShowEditor(const TQString&, uint);
	void slotFileOpened(EditorPage*, const TQString&);
	void slotFileSaved(const TQString&, bool);
	void slotCscopeError(const TQString&);
	void slotBuildProgress(int, int);
	void slotBuildInvIndex();
	void slotBuildFinished(uint);
	void slotBuildAborted();
	void slotApplyPref();
	void slotShowCursorPos(uint, uint);
	void slotQueryShowEditor(const TQString&, uint);
	void slotDropEvent(TQDropEvent*);
	void slotCscopeVerified(bool, uint);
};

#endif