summaryrefslogtreecommitdiffstats
path: root/lib/widgets/kdevhtmlpart.h
blob: 465fb0a375c84f252ac6b757f4605ec29c2315d5 (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
#ifndef __KDEVHTMLPART_H__
#define __KDEVHTMLPART_H__

#include <stdlib.h>

#include <tqdatetime.h>

#include <khtml_part.h>

/**
@file kdevhtmlpart.h
Customized KHTML part for KDevelop.
*/

class KAction;
class KToolBarPopupAction;
class KParts::ReadOnlyPart;

struct DocumentationHistoryEntry {
    KURL url;
    int id;
    
    DocumentationHistoryEntry() {}
    DocumentationHistoryEntry( const KURL& u ): url( u ) 
    {
        id = abs( TQTime::currentTime().msecsTo( TQTime() ) );	// nasty, but should provide a reasonably unique number
    }
};

/**
Customized KHTML part for KDevelop.
Used as HTML documentation and file viewer. 

Represents customized BrowserViewGUI mode of KHTMLPart. Provides also actions for:
- reload;
- stop;
- duplicate;
- print;
- copy text;
- back;
- forward.
.
It has it's own popup menu and font/zoom settings.
*/
class KDevHTMLPart : public KHTMLPart
{
    Q_OBJECT

public:
    
    enum Options { CanDuplicate=1, CanOpenInNewWindow=2 };

    KDevHTMLPart();
    
    void setContext(const TQString &context);
    TQString context() const;
    virtual bool openURL(const KURL &url);
    static TQString resolveEnvVarsInURL(const TQString& url);
    
    void setOptions(int options) { m_options = options; }

signals:
    void fileNameChanged(KParts::ReadOnlyPart *part);

protected slots:

    void slotStarted(KIO::Job *);
    void slotCompleted();
    void slotCancelled(const TQString &errMsg);
    
    void openURLRequest(const KURL &url);
    void popup( const TQString & url, const TQPoint & p );
    
    void slotReload();
    void slotStop();
    virtual void slotDuplicate() = 0;
    virtual void slotOpenInNewWindow(const KURL &url) = 0;
    void slotPrint();
    void slotCopy();
    void slotSelectionChanged();

    void slotBack();
    void slotForward();
    void slotBackAboutToShow();
    void slotForwardAboutToShow();

    void slotPopupActivated( int id );
    void addHistoryEntry();
  
  
private:

    TQValueList< DocumentationHistoryEntry > m_history;
    TQValueList< DocumentationHistoryEntry >::Iterator m_Current;

    KToolBarPopupAction* m_backAction;
    KToolBarPopupAction* m_forwardAction;
    
    bool m_restoring;

    TQString m_context;
    KAction *stopAction;
    KAction *reloadAction;
    KAction *duplicateAction;
    KAction *printAction;
    KAction *copyAction;
    
    int m_options;
};

#endif