1/*
2 * This file is part of the KDE Help Center
3 *
4 * Copyright (C) 2002 Frerich Raabe <raabe@kde.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#ifndef KHC_HISTORY_H
21#define KHC_HISTORY_H
22
23#include <KUrl>
24
25#include <QObject>
26
27#include <QMenu>
28#include <QList>
29
30class KActionCollection;
31class KXmlGuiWindow;
32class KToolBarPopupAction;
33class QMenu;
34
35namespace KHC {
36
37class View;
38
39class History : public QObject
40{
41 Q_OBJECT
42 public:
43 friend class foo; // to make gcc shut up
44 struct Entry
45 {
46 Entry() : view( 0 ), search( false ) {}
47
48 View *view;
49 KUrl url;
50 QString title;
51 QByteArray buffer;
52 bool search;
53 };
54
55 static History &self();
56
57 void setupActions( KActionCollection *coll );
58 void updateActions();
59
60 void installMenuBarHook( KXmlGuiWindow *mainWindow );
61
62 void createEntry();
63 void updateCurrentEntry( KHC::View *view );
64
65 Q_SIGNALS:
66 void goInternalUrl( const KUrl & );
67 void goUrl( const KUrl & );
68
69 private Q_SLOTS:
70 void backActivated( QAction *action );
71 void fillBackMenu();
72 void forwardActivated( QAction *action );
73 void fillForwardMenu();
74 void goMenuActivated( QAction* action );
75 void fillGoMenu();
76 void back();
77 void forward();
78 void goHistoryActivated( int steps );
79 void goHistory( int steps );
80 void goHistoryDelayed();
81
82 private:
83 History();
84 History( const History &rhs );
85 History &operator=( const History &rhs );
86 ~History();
87
88 typedef QList<Entry*> EntryList;
89
90 bool canGoBack() const;
91 bool canGoForward() const;
92 void fillHistoryPopup( QMenu *, bool, bool, bool, uint = 0 );
93
94 /**
95 * dumps the history with a kDebug and mark wihch one is the current one
96 * This is a debugging function.
97 */
98 void dumpHistory() const;
99
100 static History *m_instance;
101
102 EntryList m_entries;
103 EntryList::Iterator m_entries_current;
104
105
106 int m_goBuffer;
107 int m_goMenuIndex;
108 int m_goMenuHistoryStartPos;
109 int m_goMenuHistoryCurrentPos;
110 public:
111 KToolBarPopupAction *m_backAction;
112 KToolBarPopupAction *m_forwardAction;
113};
114
115}
116
117#endif // KHC_HISTORY_H
118// vim:ts=2:sw=2:et
119