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
|
/* This file is part of the KDE project
Copyright (C) 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
Copyright (C) 2002 Bernd Gehrmann <bernd@kdevelop.org>
Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
Copyright (C) 2003 Harald Fernengel <harry@kdevelop.org>
Copyright (C) 2003 Jens Dagerbo <jens.dagerbo@swipnet.se>
Copyright (C) 2004 Alexander Dymo <adymo@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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 Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KDEV_PARTCONTROLLER_H
#define KDEV_PARTCONTROLLER_H
#include <kurl.h>
#include <kparts/partmanager.h>
#include <ktrader.h>
/**
@file kdevpartcontroller.h
KDevelop part controller interface.
*/
namespace KParts
{
class ReadOnlyPart;
}
/**Document state enum.*/
enum DocumentState
{
Clean, /**<Document is not touched.*/
Modified, /**<Document is modified inside a shell.*/
Dirty, /**<Document is modified by an external process.*/
DirtyAndModified /**<Document is modified inside a shell and at the same time by an external process.*/
};
/**
Interface to control loaded parts and other documents.
Part controller works with embedded into the shell parts. Such parts are usually editors,
GUI designers, etc.
*/
class KDevPartController: public KParts::PartManager
{
Q_OBJECT
public:
/**Constructor.
@param parent The parent object.*/
KDevPartController(QWidget *parent);
/**Call this before a call to @ref editDocument to set the encoding of the
document to be opened.
@param encoding The encoding to open as.*/
virtual void setEncoding(const QString &encoding) = 0;
/**Opens a new or existing document.
@param url The URL of the document to open.
@param lineNum The line number to place the cursor at, if applicable.
@param col The column number to place the cursor at, if applicable.*/
virtual void editDocument(const KURL &url, int lineNum=-1, int col=-1) = 0;
/**Opens a new or existing document by splitting the view with the current,
if applicable. Offers split views of source code and header files for instance.
@param url The URL of the document to open.
@param lineNum The line number to place the cursor at, if applicable.
@param col The column number to place the cursor at, if applicable.*/
virtual void splitCurrentDocument(const KURL &url, int lineNum=-1, int col=-1) = 0;
/**Scrolls the viewport of the already opened document to the specified line
and column if applicable, but does not give focus to the document.
@param url The URL of the already opened document.
@param lineNum The line number to place the cursor at, if applicable.
@param col The column number to place the cursor at, if applicable.*/
virtual void scrollToLineColumn(const KURL &url, int lineNum=-1, int col=-1, bool storeHistory = false ) = 0;
/**Shows a HTML document in the documentation viewer.
@param url The URL of the document to view.
@param newWin If true, the new window will be created instead of using current.*/
virtual void showDocument(const KURL &url, bool newWin = false) = 0;
/**Embeds a part into the main area of the mainwindow.
@param part The part to embed.
@param name The name of the part.
@param shortDescription Currently not used.*/
virtual void showPart(KParts::Part* part, const QString& name, const QString& shortDescription ) = 0;
/**Finds the embedded part corresponding to a given URL.
@param url The URL of the document.
@return The corresponding part, 0 if not found.*/
virtual KParts::ReadOnlyPart *partForURL(const KURL & url) = 0;
/**Finds the embedded part corresponding to a given main widget
@param widget The parts main widget.
@return The corresponding part, 0 if not found.*/
virtual KParts::Part *partForWidget(const QWidget *widget) = 0;
/**@return The list of open documents*/
virtual KURL::List openURLs() = 0;
/**Saves all open files.
@return false if it was cancelled by the user, true otherwise */
virtual bool saveAllFiles() = 0;
/**Saves a list of files.
@param list The list of URLs to save.
@return false if it was cancelled by the user, true otherwise */
virtual bool saveFiles(const KURL::List &list) = 0;
/**Reloads all open files.*/
virtual void revertAllFiles() = 0;
/**Reloads a list of files.
* @param list The list of URLs to reload.*/
virtual void revertFiles(const KURL::List &list) = 0;
/**Closes all open files.*/
virtual bool closeAllFiles() = 0;
/**Closes a list of files.
@param list The list of URLs for the files to close.*/
virtual bool closeFiles(const KURL::List &list) = 0;
/**Closes this part (closes the window/tab for this part).
@param part The part to close.
@return true if the part was sucessfuly closed.*/
virtual bool closePart(KParts::Part *part) = 0;
/**Activate this part.
@param part The part to activate.*/
virtual void activatePart( KParts::Part * part ) = 0;
/**Checks the state of a document.
@param url The URL to check.
@return The DocumentState enum corresponding to the document state.*/
virtual DocumentState documentState( KURL const & url ) = 0;
signals:
/**Emitted when a document has been saved.*/
void savedFile(const KURL &);
/**Emitted when a document has been loaded.*/
void loadedFile(const KURL &);
/**Emitted when a document has been closed.*/
void closedFile(const KURL &);
/**Emitted when a file has been modified outside of KDevelop.*/
void fileDirty(const KURL &);
/**This is typically emitted when an editorpart does "save as"
which will change the part's URL.*/
void partURLChanged(KParts::ReadOnlyPart *);
/**This is emitted when the document changes,
either internally or on disc.*/
void documentChangedState(const KURL &, DocumentState);
};
#endif
|