summaryrefslogtreecommitdiffstats
path: root/src/app/KViewer/panelviewer.h
blob: 2875f92bc9e62b2179e23ffbd74f95b1f2a5e6cb (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
#ifndef _SUPERVIEW_H
#define _SUPERVIEW_H

#include <kurl.h>
#include <tqstring.h>
#include <tqwidgetstack.h>
#include <tdeparts/part.h>
#include <tdeio/job.h>
#include <tdetempfile.h>
#include <tqdict.h>
#include <tqlabel.h>

#include "krviewer.h"


class PanelViewerBase: public TQWidgetStack {
	TQ_OBJECT
  

public:
	PanelViewerBase( TQWidget *parent = 0 );
	virtual ~PanelViewerBase();
	inline KURL url() const { return curl; }
	inline void setUrl( KURL url ) { emit urlChanged( this, url ); curl = url; }
	inline KParts::ReadOnlyPart* part() const { return cpart; }
	virtual bool isModified() { return false; }
	virtual bool isEditor() = 0;

public slots:
	virtual KParts::ReadOnlyPart* openURL( const KURL&, KrViewer::Mode=KrViewer::Generic ){ return 0;} 
	virtual bool closeURL(){ return false; }
	virtual bool queryClose() { return true; }

signals:
	void openURLRequest( const KURL &url );
	void urlChanged( PanelViewerBase *, const KURL & );

protected:
	TQDict<KParts::ReadOnlyPart> *mimes;
	KParts::ReadOnlyPart *cpart;

	TQString cmimetype;
	KURL curl;
	TQLabel *fallback;

};

class PanelViewer: public PanelViewerBase {
	TQ_OBJECT
  
public slots:
	KParts::ReadOnlyPart* openURL( const KURL &url, KrViewer::Mode mode=KrViewer::Generic );
	bool closeURL();

public:
	PanelViewer( TQWidget *parent = 0 );
	~PanelViewer();

	virtual bool isEditor() { return false; }

protected:
	KParts::ReadOnlyPart *getPart( TQString mimetype );
	KParts::ReadOnlyPart*  getHexPart();
	void oldHexViewer(KTempFile& tmpFile);
};

class PanelEditor: public PanelViewerBase {
	TQ_OBJECT
  
public:
	virtual bool isModified();
	virtual bool isEditor() { return true; }

public slots:
	KParts::ReadOnlyPart* openURL( const KURL &url, KrViewer::Mode mode=KrViewer::Generic );
	bool closeURL();
	bool queryClose();
	void slotStatResult( TDEIO::Job* job );

public:
	PanelEditor( TQWidget *parent = 0 );
	~PanelEditor();

protected:
	KParts::ReadWritePart* getPart( TQString mimetype );

	bool busy;
	TDEIO::UDSEntry entry;
};

#endif