summaryrefslogtreecommitdiff
path: root/src/bookmarks.h
blob: 7b4bcdef061ae069d6a01e6df92cfebb00e2cf78 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* ============================================================
*
* This file is a part of the rekonq project
*
* Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* 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, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */



#ifndef BOOKMARKS_H
#define BOOKMARKS_H

// KDE Includes
#include <KBookmarkOwner>
#include <KBookmarkManager>
#include <KBookmarkMenu>
#include <KUrl>
#include <KMenu>
#include <KActionCollection>
#include <KMainWindow>

class MainWindow;

/** 
 * Inherited from KBookmarkOwner, this class allows to manage 
 * bookmarks as actions
 *
 * @author Andrea Diamantini <adjam7@gmail.com>
 * @since 4.x
 */
class OwnBookMarks : public QObject , public KBookmarkOwner
{
Q_OBJECT

public:

    /**  
     * The class ctor.
     *
     * @param parent the pointer to the browser mainwindow. We need it
     *               to link bookmarks actions with the right window 
     *               where load url in
     */
    OwnBookMarks(KMainWindow *parent);

    /**
     * This function is called when a bookmark is selected and belongs to 
     * the ancestor class.
     * This method actually emits signal to load bookmark's url without
     * considering mousebuttons or keyboard modifiers.
     *
     * @param b  the bookmark to open
     * @param mb the mouse buttons clicked to select the bookmark
     * @param km the keyboard modifiers pushed when the bookmark was selected
     */
    virtual void openBookmark (const KBookmark &b , Qt::MouseButtons mb, Qt::KeyboardModifiers km);

    
    /** 
     * this method, from KBookmarkOwner interface, allows to add the current page
     * to the bookmark list, returning the URL page as QString.
     *
     * @return the current page's URL
     */
    virtual QString currentUrl() const;

    /** 
     * this method, from KBookmarkOwner interface, allows to add the current page
     * to the bookmark list, returning the title's page as QString.
     *
     * @return the current page's title
     */
    virtual QString currentTitle() const;

signals:
    /**
     * This signal is emitted when an url has to be loaded 
     *
     * @param url the URL to load
     *
     */
    void openUrl(const KUrl &);

private:
    // the MainWindow pointer
    MainWindow *m_parent;
};


// ------------------------------------------------------------------------------

/** 
 * This class represent the rekonq bookmarks menu.
 * It's just a simple class inherited from KBookmarkMenu
 *
 * @author Andrea Diamantini <adjam7@gmail.com>
 * @since 4.x
 *
 */
class BookmarksMenu : public KBookmarkMenu
{
Q_OBJECT

public:
    BookmarksMenu( KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac);

    KMenu *viewContextMenu(QAction* action);
};

// ------------------------------------------------------------------------------


/** 
 * This class represent the interface to rekonq bookmarks system.
 * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided
 * from this class.
 * So it implements code to have each one
 *
 * @author Andrea Diamantini <adjam7@gmail.com>
 * @since 4.x
 *
 */
class BookmarksProvider : public QObject
{
Q_OBJECT

public:
    /** 
     * Class constructor. Connect BookmarksProvider with bookmarks source
     * (actually konqueror's bookmarks)
     *
     * @param parent The MainWindow to provide bookmarks objects
     *
     */
    BookmarksProvider(KMainWindow* parent);

    /** 
     * Customize bookmarks toolbar
     *
     * @param toolbar the toolbar to customize
     */
    void provideBmToolbar(KToolBar* toolbar);

    /** 
     * Generate the Bookmarks Menu
     *
     * @return the Bookmarks Menu
     *
     */
    KMenu *bookmarksMenu();

public slots:
    void contextMenu(const QPoint & point);

private:
    KMainWindow *m_parent;
    OwnBookMarks *m_owner;
    KBookmarkManager *m_manager;
    KActionCollection *m_ac;
    BookmarksMenu *m_bmMenu;
    KToolBar *m_bmToolbar;
};

#endif