summaryrefslogtreecommitdiffstats
path: root/krusader/KViewer/krviewer.h
blob: 99e71757953266e5d41730e15b45a31ca3d6e186 (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
/***************************************************************************
                         krviewer.h  -  description
                            -------------------
   begin                : Thu Apr 18 2002
   copyright            : (C) 2002 by Shie Erlich & Rafi Yanai
   email                : 
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 KRVIEWER_H
#define KRVIEWER_H

#include <tqwidget.h>
#include <tqptrlist.h>
#include <tdeparts/mainwindow.h>
#include <ktempfile.h>
#include <tdeparts/partmanager.h>
#include <tdeparts/browserextension.h>
#include <tqguardedptr.h>
#include <ktabwidget.h>

#include "../krusader.h"


/**
  *@author Shie Erlich & Rafi Yanai
  */

class TQPopupMenu;
class PanelViewerBase;

class KrViewer : public KParts::MainWindow {
	Q_OBJECT
  
public:
	virtual ~KrViewer();
	
	enum Mode{Generic,Text,Hex};

	static void view( KURL url, TQWidget * parent = krApp );
	static void view( KURL url, Mode mode, bool new_window, TQWidget * parent = krApp );
	static void edit( KURL url, TQWidget * parent );
	static void edit( KURL url, Mode mode=Text, int new_window=-1, TQWidget * parent = krApp );
	
	virtual bool eventFilter ( TQObject * watched, TQEvent * e );

public slots:
	void keyPressEvent( TQKeyEvent *e );
	void createGUI( KParts::Part* );

	void viewGeneric();
	void viewText();
	void viewHex();
	void editText();

	void print();
	void copy();

	void tabChanged(TQWidget* w);
	void tabURLChanged( PanelViewerBase * pvb, const KURL &url );
	void tabCloseRequest(TQWidget *w);
	void tabCloseRequest();

	void nextTab();
	void prevTab();
	void detachTab();
	
	void checkModified();

protected:
	virtual bool queryClose();
	virtual bool queryExit();
	virtual void windowActivationChange ( bool oldActive );

	virtual void focusInEvent( TQFocusEvent * ){ if( viewers.remove( this ) ) viewers.prepend( this ); } // move to first

private:
	KrViewer( TQWidget *parent = 0, const char *name = 0 );
	void addTab(PanelViewerBase* pvb, TQString msg,TQString iconName, KParts::Part* part);
	PanelViewerBase * getPanelViewerBase( KParts::Part* part);
	void updateActions( PanelViewerBase * base );
	
	static KrViewer* getViewer(bool new_window);	

	KParts::PartManager manager;
	TQPopupMenu* viewerMenu;
	KTempFile tmpFile;
	KTabWidget tabBar;
	TQGuardedPtr<TQWidget> returnFocusTo;
	PanelViewerBase * returnFocusTab;
	
	int detachActionIndex;

	KAction *printAction;
	KAction *copyAction;

	int tabCloseID;
	int closeID;

	static TQPtrList<KrViewer> viewers; // the first viewer is the active one
	TQValueList<int>    reservedKeys;   // the reserved key sequences
	TQValueList<int>    reservedKeyIDs; // the IDs of the reserved keys
};

class Invoker : public TQObject {
	Q_OBJECT
  
	
public:
	Invoker( TQObject *recv, const char * slot ) {
		connect( this, TQT_SIGNAL( invokeSignal() ), recv, slot );
	}
	
	void invoke() {
		emit invokeSignal();
	}
	
signals:
	void invokeSignal();
};

#endif