summaryrefslogtreecommitdiffstats
path: root/src/kile/kileviewmanager.h
blob: 2050a2c5b79e21322d1b2945033c1ee81f0c7096 (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
//
// C++ Interface: kileviewmanager
//
// Description: 
//
//
// Author: Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net>, (C) 2004
//         Michel Ludwig <michel.ludwig@kdemail.net>, (C) 2006
//

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
 
#ifndef KILEVIEWKILEVIEWMANAGER_H
#define KILEVIEWKILEVIEWMANAGER_H

#include <tqobject.h>
#include <tqwidgetstack.h>

#include <ktabwidget.h>

class TQPixmap;

class KURL;
class KXMLGUIClient;

class KileInfo;
class KileEventFilter;
class KileProjectView;

namespace Kate {
	class Document;
	class View;
}

namespace KileDocument {
	class Info;
	class TextInfo;
}

namespace KileView 
{

//TODO inherit from KParts::Manager
class Manager : public TQObject
{
	Q_OBJECT
  TQ_OBJECT

public:
	Manager(KileInfo *ki, TQObject *parent = 0, const char *name = 0);

	~Manager();
   
public:
	void setClient(TQObject *receiver, KXMLGUIClient *client);

	Kate::View* currentTextView() const;
	TQPtrList<Kate::View>& textViews() {return m_textViewList;}
	Kate::View* textView(int i) { return m_textViewList.at(i); }
	Kate::View* textView(KileDocument::TextInfo *info);
	int getIndexOf(Kate::View* view) const;
	unsigned int getTabCount() const;

	void createTabs(TQWidget *);
	Kate::View* createTextView(KileDocument::TextInfo *info, int index = -1);
	KTabWidget* tabs() { return m_tabs; }

	void unplugKatePartMenu(Kate::View* view);

// 	void setProjectView(KileProjectView *view) { m_projectview = view; }
// 	KileProjectView *projectView() { return m_projectview; } commented out by tbraun, better use signal/slot stuff

public slots:
	Kate::View* switchToTextView(const KURL & url, bool requestFocus = false);

	void closeWidget(TQWidget *);
	void removeView(Kate::View *view);

	void setTabLabel(TQWidget *view, const TQString & name) { m_tabs->setTabLabel(view, name); }
	void changeTab(TQWidget *view, const TQPixmap & icon, const TQString & name) { m_tabs->changeTab(view, icon, name); }

	void updateStructure(bool parse = false, KileDocument::Info *docinfo = 0L);

	void gotoNextView();
	void gotoPrevView();

	void reflectDocumenttqStatus(Kate::Document*, bool, unsigned char);

	void onKatePopupMenuRequest(void);
	void convertSelectionToLaTeX(void);
	void pasteAsLaTeX(void);
	void quickPreviewPopup();

protected slots:
	void testCanDecodeURLs(const TQDragMoveEvent *e, bool &accept);
	void replaceLoadedURL(TQWidget *w, TQDropEvent *e);

	/**
	 * 
	 **/
	void urlChanged(KileDocument::Info* info, const KURL& url);

signals:
	void activateView(TQWidget *, bool);
	void prepareForPart(const TQString &);
	void startQuickPreview(int);

private:
	KileInfo			*m_ki;
	Kate::View			*m_activeTextView;
// 	KileProjectView		*m_projectview;
	TQPtrList<Kate::View>		m_textViewList;
	KTabWidget 			*m_tabs;
	TQObject				*m_receiver;
	KXMLGUIClient		*m_client;
	TQWidgetStack			*m_widgetStack;
	TQWidget				*m_emptyDropWidget;

};

/**
 * Little helper widget to overcome the limitation that KTabWidget doesn't honour drop events when
 * there are no tabs: the DropWidget is shown instead of KTabWidget when there are no tabs.
 */
class DropWidget : public TQWidget {
	Q_OBJECT
  TQ_OBJECT

	public:
		DropWidget(TQWidget * parent = 0, const char * name = 0, WFlags f = 0);
		virtual ~DropWidget();

		virtual void dragMoveEvent(TQDragMoveEvent *e);

		virtual void dropEvent(TQDropEvent *e);

	signals:
		void testCanDecode(const TQDragMoveEvent *, bool &);
		void receivedDropEvent(TQDropEvent *);
};

}

#endif