summaryrefslogtreecommitdiffstats
path: root/src/app/BookMan/krbookmarkhandler.h
blob: 818c3c943292bbb7f5ab1be222b2d225f4fe8cb8 (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
#ifndef KRBOOKMARK_HANDLER_H
#define KRBOOKMARK_HANDLER_H

#include "krbookmark.h"
#include <tqobject.h>
#include <tqguardedptr.h>
#include <tdepopupmenu.h>
#include <kurl.h>
#include <tqptrdict.h>
#include <tqvaluelist.h>
#include <tqdom.h>
#include <tqmap.h>

class TDEActionCollection;
class KBookmarkManager;

class KrBookmarkHandler: public TQObject {
	TQ_OBJECT
  
	friend class KrAddBookmarkDlg;
	enum Actions { BookmarkCurrent=0, ManageBookmarks };
public:
	KrBookmarkHandler();
	~KrBookmarkHandler();
	void populate(TDEPopupMenu *menu);
	void addBookmark(KrBookmark *bm, KrBookmark *parent = 0);
	void bookmarkCurrent(KURL url);

protected:
	void deleteBookmark(KrBookmark *bm);
	void importFromFile();
	bool importFromFileBookmark(TQDomElement &e, KrBookmark *parent, TQString path, TQString *errorMsg);
	bool importFromFileFolder(TQDomNode &first, KrBookmark *parent, TQString path, TQString *errorMsg);
	void exportToFile();
	void exportToFileFolder(TQDomDocument &doc, TQDomElement &parent, KrBookmark *folder);
	void exportToFileBookmark(TQDomDocument &doc, TQDomElement &where, KrBookmark *bm);
	void clearBookmarks(KrBookmark *root);
	void buildMenu(KrBookmark *parent, TDEPopupMenu *menu);

	bool eventFilter( TQObject *obj, TQEvent *ev );
	
	void rightClicked( TQPopupMenu *menu, int id, KrBookmark *bm );
	void rightClickOnSpecialBookmark();
	
	void removeReferences( KrBookmark *root, KrBookmark *bmToRemove );
	
protected slots:
	void menuOperation(int id);
	void bookmarksChanged(const TQString&, const TQString&);
	void slotActivated(const KURL& url);

private:
	TDEActionCollection *_collection, *_privateCollection;
	KrBookmark *_root;
	// the whole KBookmarkManager is an ugly hack. use it until we have our own
	KBookmarkManager *manager;
	bool _middleClick; // if true, the user clicked the middle button to open the bookmark
	
	TQGuardedPtr<TDEPopupMenu>            _mainBookmarkPopup; // main bookmark popup menu
	TQValueList<int>                    _specialBookmarkIDs; // the ID list of the special bookmarks
	TQPtrDict<TQMap<int,KrBookmark*> >   _bookmarkIDTable;    // the IDs of the bookmarks
};

#endif // KRBOOKMARK_HANDLER_H