1
/* This file is part of the KDE project
2
Copyright (C) 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
3
Copyright (C) 2002 Bernd Gehrmann <bernd@kdevelop.org>
4
Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
5
Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
6
Copyright (C) 2003 Harald Fernengel <harry@kdevelop.org>
7
Copyright (C) 2003 Jens Dagerbo <jens.dagerbo@swipnet.se>
8
Copyright (C) 2004 Alexander Dymo <adymo@kdevelop.org>
10
This library is free software; you can redistribute it and/or
11
modify it under the terms of the GNU Library General Public
12
License as published by the Free Software Foundation; either
13
version 2 of the License, or (at your option) any later version.
15
This library is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
Library General Public License for more details.
20
You should have received a copy of the GNU Library General Public License
21
along with this library; see the file COPYING.LIB. If not, write to
22
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23
Boston, MA 02111-1307, USA.
25
#ifndef KDEV_PARTCONTROLLER_H
26
#define KDEV_PARTCONTROLLER_H
29
#include <kparts/partmanager.h>
33
@file kdevpartcontroller.h
34
KDevelop part controller interface.
42
/**Document state enum.*/
45
Clean, /**<Document is not touched.*/
46
Modified, /**<Document is modified inside a shell.*/
47
Dirty, /**<Document is modified by an external process.*/
48
DirtyAndModified /**<Document is modified inside a shell and at the same time by an external process.*/
52
Interface to control loaded parts and other documents.
53
Part controller works with embedded into the shell parts. Such parts are usually editors,
56
class KDevPartController: public KParts::PartManager
62
@param parent The parent object.*/
63
KDevPartController(QWidget *parent);
65
/**Call this before a call to @ref editDocument to set the encoding of the
66
document to be opened.
67
@param encoding The encoding to open as.*/
68
virtual void setEncoding(const QString &encoding) = 0;
70
/**Opens a new or existing document.
71
@param url The URL of the document to open.
72
@param lineNum The line number to place the cursor at, if applicable.
73
@param col The column number to place the cursor at, if applicable.*/
74
virtual void editDocument(const KURL &url, int lineNum=-1, int col=-1) = 0;
76
/**Opens a new or existing document by splitting the view with the current,
77
if applicable. Offers split views of source code and header files for instance.
78
@param url The URL of the document to open.
79
@param lineNum The line number to place the cursor at, if applicable.
80
@param col The column number to place the cursor at, if applicable.*/
81
virtual void splitCurrentDocument(const KURL &url, int lineNum=-1, int col=-1) = 0;
83
/**Scrolls the viewport of the already opened document to the specified line
84
and column if applicable, but does not give focus to the document.
85
@param url The URL of the already opened document.
86
@param lineNum The line number to place the cursor at, if applicable.
87
@param col The column number to place the cursor at, if applicable.*/
88
virtual void scrollToLineColumn(const KURL &url, int lineNum=-1, int col=-1, bool storeHistory = false ) = 0;
90
/**Shows a HTML document in the documentation viewer.
91
@param url The URL of the document to view.
92
@param newWin If true, the new window will be created instead of using current.*/
93
virtual void showDocument(const KURL &url, bool newWin = false) = 0;
95
/**Embeds a part into the main area of the mainwindow.
96
@param part The part to embed.
97
@param name The name of the part.
98
@param shortDescription Currently not used.*/
99
virtual void showPart(KParts::Part* part, const QString& name, const QString& shortDescription ) = 0;
101
/**Finds the embedded part corresponding to a given URL.
102
@param url The URL of the document.
103
@return The corresponding part, 0 if not found.*/
104
virtual KParts::ReadOnlyPart *partForURL(const KURL & url) = 0;
106
/**Finds the embedded part corresponding to a given main widget
107
@param widget The parts main widget.
108
@return The corresponding part, 0 if not found.*/
109
virtual KParts::Part *partForWidget(const QWidget *widget) = 0;
111
/**@return The list of open documents*/
112
virtual KURL::List openURLs() = 0;
114
/**Saves all open files.
115
@return false if it was cancelled by the user, true otherwise */
116
virtual bool saveAllFiles() = 0;
118
/**Saves a list of files.
119
@param list The list of URLs to save.
120
@return false if it was cancelled by the user, true otherwise */
121
virtual bool saveFiles(const KURL::List &list) = 0;
123
/**Reloads all open files.*/
124
virtual void revertAllFiles() = 0;
126
/**Reloads a list of files.
127
* @param list The list of URLs to reload.*/
128
virtual void revertFiles(const KURL::List &list) = 0;
130
/**Closes all open files.*/
131
virtual bool closeAllFiles() = 0;
133
/**Closes a list of files.
134
@param list The list of URLs for the files to close.*/
135
virtual bool closeFiles(const KURL::List &list) = 0;
137
/**Closes this part (closes the window/tab for this part).
138
@param part The part to close.
139
@return true if the part was sucessfuly closed.*/
140
virtual bool closePart(KParts::Part *part) = 0;
142
/**Activate this part.
143
@param part The part to activate.*/
144
virtual void activatePart( KParts::Part * part ) = 0;
146
/**Checks the state of a document.
147
@param url The URL to check.
148
@return The DocumentState enum corresponding to the document state.*/
149
virtual DocumentState documentState( KURL const & url ) = 0;
153
/**Emitted when a document has been saved.*/
154
void savedFile(const KURL &);
156
/**Emitted when a document has been loaded.*/
157
void loadedFile(const KURL &);
159
/**Emitted when a document has been closed.*/
160
void closedFile(const KURL &);
162
/**Emitted when a file has been modified outside of KDevelop.*/
163
void fileDirty(const KURL &);
165
/**This is typically emitted when an editorpart does "save as"
166
which will change the part's URL.*/
167
void partURLChanged(KParts::ReadOnlyPart *);
169
/**This is emitted when the document changes,
170
either internally or on disc.*/
171
void documentChangedState(const KURL &, DocumentState);