1
/* This file is part of the KDE project
2
Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3
Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
4
Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License version 2 as published by the Free Software Foundation.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
Boston, MA 02110-1301, USA.
21
#ifndef KATE_VIEWSPACE_H
22
#define KATE_VIEWSPACE_H
24
#include <ktexteditor/view.h>
25
#include <ktexteditor/document.h>
26
#include <ktexteditor/modificationinterface.h>
32
class KateViewManager;
37
class KateViewSpace : public QWidget
42
explicit KateViewSpace(KateViewManager *, QWidget *parent = 0, const char *name = 0);
45
* Returns \e true, if this view space is currently the active view space.
50
* Depending on @p active, mark this view space as active or inactive.
51
* Called from the view manager.
53
void setActive(bool active);
56
* Create new view for given document
57
* @param doc document to create view for
58
* @return new created view
60
KTextEditor::View *createView(KTextEditor::Document *doc);
61
void removeView(KTextEditor::View *v);
63
bool showView(KTextEditor::View *view) {
64
return showView(view->document());
66
bool showView(KTextEditor::Document *document);
68
KTextEditor::View *currentView();
70
void saveConfig(KConfigBase *config, int myIndex, const QString &viewConfGrp);
71
void restoreConfig(KateViewManager *viewMan, const KConfigBase *config, const QString &group);
74
* Returns the document LRU list of this view space.
76
QVector<KTextEditor::Document*> lruDocumentList() const;
79
* Called by the view manager if a viewspace was closed.
80
* The documents of the closed are merged into this viewspace
82
void mergeLruList(const QVector<KTextEditor::Document*> & lruList);
85
* Called by the view manager to notify that new documents were created
86
* while this view space was active. If @p append is @e true, the @p doc
87
* is appended to the lru document list, otherwise, it is prepended.
89
void registerDocument(KTextEditor::Document *doc, bool append = true);
92
* Event filter to catch events from view space tool buttons.
94
bool eventFilter(QObject *obj, QEvent *event);
97
* Focus the previous tab in the tabbar.
102
* Focus the next tab in the tabbar.
107
void documentDestroyed(QObject *doc);
108
void updateDocumentName(KTextEditor::Document *doc);
109
void updateDocumentState(KTextEditor::Document *doc);
112
void statusBarToggled();
113
void tabBarToggled();
114
void changeView(int buttonId);
117
* Calls this slot to make this view space the currently active view space.
118
* Making it active goes through the KateViewManager.
119
* @param focusCurrentView if @e true, the current view will get focus
121
void makeActive(bool focusCurrentView = true);
124
* Add a tab for @p doc at position @p index.
126
void insertTab(int index, KTextEditor::Document * doc);
129
* Remove tab for @p doc, and return the index (position)
130
* of the removed tab.
132
int removeTab(KTextEditor::Document * doc, bool documentDestroyed);
135
* Remove @p count tabs, since the tab bar shrinked.
137
void removeTabs(int count);
140
* Add @p count tabs, since the tab bar grew.
142
void addTabs(int count);
145
* This slot is called by the tabbar, if tab @p id was closed through the
148
void closeTabRequest(int id);
151
* This slot is called when the context menu is requested for button
152
* @p id at position @p globalPos.
153
* @param id the button, or -1 if the context menu was requested on
154
* at a place where no tab exists
155
* @param globalPos the position of the context menu in global coordinates
157
void showContextMenu(int id, const QPoint & globalPos);
160
* Called to create a new empty document.
162
void createNewDocument();
165
* Update the quick open button to reflect the currently hidden tabs.
167
void updateQuickOpen();
171
* Returns the amount of documents in KateDocManager that currently
172
* have no tab in this tab bar.
174
int hiddenDocuments() const;
177
// Kate's view manager
178
KateViewManager *m_viewManager;
180
// config group string, used for restoring View session configuration
183
// flag that indicates whether this view space is the active one.
184
// correct setter: m_viewManager->setActiveSpace(this);
187
// widget stack that contains all KTE::Views
188
QStackedWidget *stack;
190
// document's in the view space, sorted in LRU mode:
191
// the most recently used Document is at the end of the list
192
QVector<KTextEditor::Document *> m_lruDocList;
194
// the list of views that are contained in this view space,
195
// mapped through a hash from Document to View.
196
// note: the number of entries match stack->count();
197
QHash<KTextEditor::Document*, KTextEditor::View*> m_docToView;
199
// tab bar that contains viewspace tabs
200
KateTabBar *m_tabBar;
203
QToolButton *m_split;
206
QToolButton *m_quickOpen;
208
// map from Document to button id
209
QHash<KTextEditor::Document *, int> m_docToTabId;