summaryrefslogtreecommitdiffstats
path: root/krusader/BookMan/krbookmarkhandler.cpp
blob: b62cd156e9c4d3809604c9d69da69c6a18976f6b (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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
#include "krbookmarkhandler.h"
#include "kraddbookmarkdlg.h"
#include "../krusader.h"
#include "../krslots.h"
#include "../Dialogs/popularurls.h"
#include "../VFS/vfs.h"
#include <kiconloader.h>
#include <kmessagebox.h>
#include <tqptrlist.h>
#include <tdeactioncollection.h>
#include <klocale.h>
#include <kdebug.h>
#include <kbookmarkmanager.h>
#include <kstandarddirs.h>
#include <tqfile.h>
#include <tqcursor.h>

#define SPECIAL_BOOKMARKS	true

// ------------------------ for internal use
#define BOOKMARKS_FILE	"krusader/krbookmarks.xml"
#define CONNECT_BM(X)	{ disconnect(X, TQT_SIGNAL(activated(const KURL&)), 0, 0); connect(X, TQT_SIGNAL(activated(const KURL&)), this, TQT_SLOT(slotActivated(const KURL&))); }
											
KrBookmarkHandler::KrBookmarkHandler(): TQObject(0), _middleClick(false), _mainBookmarkPopup( 0 ), _specialBookmarkIDs(), _bookmarkIDTable() {
	// create our own action collection and make the shortcuts apply only to parent
	_privateCollection = new TDEActionCollection(krApp, "private collection");
	_collection = krApp->actionCollection();

	// create _root: father of all bookmarks. it is a dummy bookmark and never shown
	_root = new KrBookmark(i18n("Bookmarks"));
	
	_bookmarkIDTable.setAutoDelete( true );
	
	// load bookmarks 
	importFromFile();

	// hack
	manager = KBookmarkManager::managerForFile(locateLocal( "data", BOOKMARKS_FILE ), false);
	connect(manager, TQT_SIGNAL(changed(const TQString&, const TQString& )), this, TQT_SLOT(bookmarksChanged(const TQString&, const TQString& )));
}

KrBookmarkHandler::~KrBookmarkHandler() {
	delete manager;
	delete _privateCollection;
}

void KrBookmarkHandler::menuOperation(int id) {
	switch (id) {
		case BookmarkCurrent:
			bookmarkCurrent(ACTIVE_PANEL->virtualPath());
			break;
		case ManageBookmarks:
			manager->slotEditBookmarks();
			break;
	}
}

void KrBookmarkHandler::bookmarkCurrent(KURL url) {
	KrAddBookmarkDlg dlg(krApp, url);
	if (dlg.exec() == KDialog::Accepted) {
		KrBookmark *bm = new KrBookmark(dlg.name(), dlg.url(), _collection);
		addBookmark(bm, dlg.folder());
	}
}

void KrBookmarkHandler::addBookmark(KrBookmark *bm, KrBookmark *folder) {
	if (folder == 0)
		folder = _root;
		
	// add to the list (bottom)
	folder->children().append(bm);

	exportToFile();
}

void KrBookmarkHandler::deleteBookmark(KrBookmark *bm) {
	if( bm->isFolder() )
		clearBookmarks( bm ); // remove the child bookmarks
	removeReferences( _root, bm );
	bm->unplugAll();
	delete bm;
	
	exportToFile();
}

void KrBookmarkHandler::removeReferences( KrBookmark *root, KrBookmark *bmToRemove ) {
	int index = root->children().find( bmToRemove );
	if( index >= 0 )
		root->children().take( index );
	
	KrBookmark *bm = root->children().first();
	while (bm) {
		if (bm->isFolder())
			removeReferences(bm, bmToRemove);
		bm = root->children().next();
	}
}

void KrBookmarkHandler::exportToFileBookmark(TQDomDocument &doc, TQDomElement &where, KrBookmark *bm) {
	if( bm->isSeparator() ) {
		TQDomElement bookmark = doc.createElement("separator");
		where.appendChild(bookmark);
	}
	else {
		TQDomElement bookmark = doc.createElement("bookmark");
		// url
		bookmark.setAttribute("href", bm->url().prettyURL());
		// icon
		bookmark.setAttribute("icon", bm->icon());
		// title
		TQDomElement title = doc.createElement("title");	
		title.appendChild(doc.createTextNode(bm->text()));
		bookmark.appendChild(title);
		
		where.appendChild(bookmark);
	}
}

void KrBookmarkHandler::exportToFileFolder(TQDomDocument &doc, TQDomElement &parent, KrBookmark *folder) {
	for (KrBookmark *bm = folder->children().first(); bm; bm = folder->children().next()) {
		if (bm->isFolder()) {
			TQDomElement newFolder = doc.createElement("folder");
			newFolder.setAttribute("icon", bm->icon());
			parent.appendChild(newFolder);
			TQDomElement title = doc.createElement("title");
			title.appendChild(doc.createTextNode(bm->text()));
			newFolder.appendChild(title);
			exportToFileFolder(doc, newFolder, bm);
		} else {
			exportToFileBookmark(doc, parent, bm);
		}
	}
}

// export to file using the xbel standard
//
//  <xbel>
//    <bookmark href="http://developer.kde.org"><title>Developer Web Site</title></bookmark>
//    <folder folded="no">
//      <title>Title of this folder</title>
//      <bookmark icon="kde" href="http://www.kde.org"><title>KDE Web Site</title></bookmark>
//      <folder toolbar="yes">
//        <title>My own bookmarks</title>
//        <bookmark href="http://www.koffice.org"><title>KOffice Web Site</title></bookmark>
//        <separator/>
//        <bookmark href="http://www.tdevelop.org"><title>KDevelop Web Site</title></bookmark>
//      </folder>
//    </folder>
//  </xbel>
void KrBookmarkHandler::exportToFile() {
	TQDomDocument doc( "xbel" );
   TQDomElement root = doc.createElement( "xbel" );
   doc.appendChild( root );

	exportToFileFolder(doc, root, _root);
	if (!doc.firstChild().isProcessingInstruction()) {
		// adding: <?xml version="1.0" encoding="UTF-8" ?> if not already present 
		TQDomProcessingInstruction instr = doc.createProcessingInstruction( "xml", 
				"version=\"1.0\" encoding=\"UTF-8\" ");
		doc.insertBefore( instr, doc.firstChild() ); 
	}

	
	TQString filename = locateLocal( "data", BOOKMARKS_FILE );
	TQFile file(filename);
	if ( file.open( IO_WriteOnly ) ) {
		TQTextStream stream( &file );
		stream.setEncoding(stream.UnicodeUTF8);
		stream << doc.toString();
		file.close();
	} else {
		KMessageBox::error(krApp, i18n("Unable to write to %1").arg(filename), i18n("Error"));
	}
}

bool KrBookmarkHandler::importFromFileBookmark(TQDomElement &e, KrBookmark *parent, TQString path, TQString *errorMsg) {
	TQString url, name, icon;
	// verify tag
	if (e.tagName() != "bookmark") {
		*errorMsg = e.tagName() + i18n(" instead of ")+"bookmark";
		return false;
	}
	// verify href
	if (!e.hasAttribute("href")) {
		*errorMsg = i18n("missing tag ")+ "href";
		return false;
	} else url = e.attribute("href");
	// verify title
	TQDomElement te = e.firstChild().toElement();
	if (te.tagName() != "title") {
		*errorMsg = i18n("missing tag ")+"title";
		return false;
	} else name = te.text();
	// do we have an icon?
	if (e.hasAttribute("icon")) {
		icon=e.attribute("icon");
	}
	// ok: got name and url, let's add a bookmark
	KrBookmark *bm = KrBookmark::getExistingBookmark(path+name, _collection);
	if (!bm) {
		bm = new KrBookmark(name, vfs::fromPathOrURL( url ), _collection, icon, path+name);
	parent->children().append(bm);
	}

	return true;
}

bool KrBookmarkHandler::importFromFileFolder(TQDomNode &first, KrBookmark *parent, TQString path, TQString *errorMsg) {
	TQString name;
	TQDomNode n = first;
	while (!n.isNull()) {
		TQDomElement e = n.toElement();
		if (e.tagName() == "bookmark") {
			if (!importFromFileBookmark(e, parent, path, errorMsg))
				return false;
		} else if (e.tagName() == "folder") {
			TQString iconName = "";
			if (e.hasAttribute("icon")) iconName=e.attribute("icon");
			// the title is the first child of the folder
			TQDomElement tmp = e.firstChild().toElement();
			if (tmp.tagName() != "title") {
				*errorMsg = i18n("missing tag ")+"title";
				return false;
			} else name = tmp.text();
			KrBookmark *folder = new KrBookmark(name, iconName);
			parent->children().append(folder);

			TQDomNode nextOne = tmp.nextSibling();
			if (!importFromFileFolder(nextOne, folder, path + name + "/", errorMsg))
				return false;
		} else if (e.tagName() == "separator") {
			parent->children().append(KrBookmark::separator());
		}
		n = n.nextSibling();
	}
	return true;
}


void KrBookmarkHandler::importFromFile() {
	clearBookmarks(_root);
	
	TQString filename = locateLocal( "data", BOOKMARKS_FILE );
	TQFile file( filename );
	if ( !file.open(IO_ReadOnly))
		return; // no bookmarks file

	TQString errorMsg;
	TQDomNode n;
	TQDomElement e;
	TQDomDocument doc( "xbel" );
	if ( !doc.setContent( &file, &errorMsg ) ) {
		goto ERROR;
	}
	// iterate through the document: first child should be "xbel" (skip all until we find it)
	n = doc.firstChild();	
	while (!n.isNull() && n.toElement().tagName()!="xbel")
		n = n.nextSibling();

	if (n.isNull() || n.toElement().tagName()!="xbel") {
		errorMsg = i18n("%1 doesn't seem to be a valid Bookmarks file").arg(filename);
		goto ERROR;
	} else n = n.firstChild(); // skip the xbel part
	importFromFileFolder(n, _root, "", &errorMsg);
	goto SUCCESS;
	
ERROR:
	KMessageBox::error(krApp, i18n("Error reading bookmarks file: %1").arg(errorMsg), i18n( "Error" ));

SUCCESS:
	file.close();
}

void KrBookmarkHandler::populate(TDEPopupMenu *menu) {
	_mainBookmarkPopup = menu;
	menu->clear();
	_bookmarkIDTable.clear();
	_specialBookmarkIDs.clear();
	buildMenu(_root, menu);
}

void KrBookmarkHandler::buildMenu(KrBookmark *parent, TDEPopupMenu *menu) {
	static int inSecondaryMenu = 0; // used to know if we're on the top menu

	// run the loop twice, in order to put the folders on top. stupid but easy :-)
	// note: this code drops the separators put there by the user
	for (KrBookmark *bm = parent->children().first(); bm; bm = parent->children().next()) {
		if (!bm->isFolder()) continue;
		TDEPopupMenu *newMenu = new TDEPopupMenu(menu);
		int id = menu->insertItem(TQIconSet(krLoader->loadIcon(bm->icon(), KIcon::Small)),
									bm->text(), newMenu, -1 /* dummy id */, -1 /* end of list */);
		
		if( !_bookmarkIDTable.find( menu ) )
			_bookmarkIDTable.insert( menu, new TQMap<int, KrBookmark *> );
		(*_bookmarkIDTable[ menu ])[ id ] = bm;
		
		++inSecondaryMenu;
		buildMenu(bm, newMenu);
		--inSecondaryMenu;
	}
	for (KrBookmark *bm = parent->children().first(); bm; bm = parent->children().next()) {
		if (bm->isFolder()) continue;
		if (bm->isSeparator() ) {
			menu->insertSeparator();
			continue;
		}
		int itemIndex = bm->plug(menu, -1 /* end of list */);
		CONNECT_BM(bm);
		
		int id = bm->itemId( itemIndex );
		if( !_bookmarkIDTable.find( menu ) )
			_bookmarkIDTable.insert( menu, new TQMap<int, KrBookmark *> );
		(*_bookmarkIDTable[ menu ])[ id ] = bm;
	}

	if (!inSecondaryMenu) {
		krConfig->setGroup( "Private" );
		bool hasPopularURLs = krConfig->readBoolEntry( "BM Popular URLs", true );
		bool hasDevices     = krConfig->readBoolEntry( "BM Devices",      true );
		bool hasLan         = krConfig->readBoolEntry( "BM Lan",          true );
		bool hasVirtualFS   = krConfig->readBoolEntry( "BM Virtual FS",   true );
		bool hasJumpback    = krConfig->readBoolEntry( "BM Jumpback",     true );
		
		int itemIndex;
		
		if( hasPopularURLs ) {
			menu->insertSeparator();
			
			// add the popular links submenu
			TDEPopupMenu *newMenu = new TDEPopupMenu(menu);
			itemIndex = menu->insertItem(TQIconSet(krLoader->loadIcon("bookmark_folder", KIcon::Small)),
										i18n("Popular URLs"), newMenu, -1 /* dummy id */, -1 /* end of list */);
			_specialBookmarkIDs.append( itemIndex );
			// add the top 15 urls
			#define MAX 15
			KURL::List list = krApp->popularUrls->getMostPopularUrls(MAX);
			KURL::List::Iterator it;
			for (it = list.begin(); it != list.end(); ++it) {
				TQString name;
				if ((*it).isLocalFile()) name = (*it).path();
				else name = (*it).prettyURL();
				// note: these bookmark are put into the private collection
				// as to not spam the general collection
				KrBookmark *bm = KrBookmark::getExistingBookmark(name, _privateCollection);
				if (!bm)
					bm = new KrBookmark(name, *it, _privateCollection);
				bm->plug(newMenu);
				CONNECT_BM(bm);
			}
			
			newMenu->insertSeparator();
			krPopularUrls->plug(newMenu);
			newMenu->installEventFilter(this);
		}
		
		// do we need to add special bookmarks?
		if (SPECIAL_BOOKMARKS) {
			if( hasDevices || hasLan || hasVirtualFS || hasJumpback )
				menu->insertSeparator();
			
			KrBookmark *bm;
			
			// note: special bookmarks are not kept inside the _bookmarks list and added ad-hoc
			if( hasDevices ) {
				bm = KrBookmark::devices(_collection);
				itemIndex = bm->plug(menu);
				_specialBookmarkIDs.append( bm->itemId( itemIndex ) );
				CONNECT_BM(bm);
			}
			
			if( hasLan ) {
				bm = KrBookmark::lan(_collection);
				itemIndex = bm->plug(menu);
				_specialBookmarkIDs.append( bm->itemId( itemIndex ) );
				CONNECT_BM(bm);
			}
			
			if( hasVirtualFS ) {
				bm = KrBookmark::virt(_collection);
				itemIndex = bm->plug(menu);
				_specialBookmarkIDs.append( bm->itemId( itemIndex ) );
				CONNECT_BM(bm);
			}
			
			if( hasJumpback ) {
				// add the jump-back button
				itemIndex = krJumpBack->plug(menu);
				_specialBookmarkIDs.append( krJumpBack->itemId( itemIndex ) );
				menu->insertSeparator();
				itemIndex = krSetJumpBack->plug(menu);
				_specialBookmarkIDs.append( krSetJumpBack->itemId( itemIndex ) );
			}
		} 
		
		if( !hasJumpback )
			menu->insertSeparator();
		
		itemIndex = menu->insertItem(krLoader->loadIcon("bookmark_add", KIcon::Small),
			i18n("Bookmark Current"), BookmarkCurrent);
		_specialBookmarkIDs.append( itemIndex );
		itemIndex = menu->insertItem(krLoader->loadIcon("bookmark", KIcon::Small),
			i18n("Manage Bookmarks"), ManageBookmarks);
		_specialBookmarkIDs.append( itemIndex );
	
		// make sure the menu is connected to us
		disconnect(menu, TQT_SIGNAL(activated(int)), 0, 0);
		connect(menu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(menuOperation(int)));
	}

	menu->installEventFilter(this);
}

void KrBookmarkHandler::clearBookmarks(KrBookmark *root) {
	KrBookmark *bm = root->children().first();
	while (bm) {	
		if (bm->isFolder())
			clearBookmarks(bm);
		else {
			bm->unplugAll();
			delete bm;
		}

		bm = root->children().next();
	}
	root->children().clear();
}

void KrBookmarkHandler::bookmarksChanged(const TQString&, const TQString&) {
	importFromFile();
}

bool KrBookmarkHandler::eventFilter( TQObject *obj, TQEvent *ev ) {
	if (ev->type() == TQEvent::MouseButtonRelease) {
		switch (TQT_TQMOUSEEVENT(ev)->button()) {
			case Qt::RightButton:
				_middleClick = false;
				if( obj->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) ) {
					int id = static_cast<TQPopupMenu*>(TQT_TQWIDGET(obj))->idAt( TQT_TQMOUSEEVENT(ev)->pos() );
					
					if( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(_mainBookmarkPopup) && _specialBookmarkIDs.contains( id ) ) {
						rightClickOnSpecialBookmark();
						return true;
					}
					
					if( _bookmarkIDTable.find( obj ) ) {
						TQMap<int, KrBookmark*> * table = _bookmarkIDTable[ obj ];
						if( table && table->count( id ) ) {
							KrBookmark *bm = (*table)[ id ];
							rightClicked( static_cast<TQPopupMenu*>(TQT_TQWIDGET(obj)), id, bm );
							return true;
						}
					}
				}
			case Qt::LeftButton:
				_middleClick = false;
				break;
			case Qt::MidButton:
				_middleClick = true;
				break;
			default:
				break;
		}
	}
	return TQObject::eventFilter(obj, ev);
}

#define POPULAR_URLS_ID        100100
#define DEVICES_ID             100101
#define LAN_ID                 100103
#define VIRTUAL_FS_ID          100102
#define JUMP_BACK_ID           100104

void KrBookmarkHandler::rightClickOnSpecialBookmark() {
	krConfig->setGroup( "Private" );
	bool hasPopularURLs = krConfig->readBoolEntry( "BM Popular URLs", true );
	bool hasDevices     = krConfig->readBoolEntry( "BM Devices",      true );
	bool hasLan         = krConfig->readBoolEntry( "BM Lan",          true );
	bool hasVirtualFS   = krConfig->readBoolEntry( "BM Virtual FS",   true );
	bool hasJumpback    = krConfig->readBoolEntry( "BM Jumpback",     true );
	
	TQPopupMenu menu( _mainBookmarkPopup );
	menu.setCaption( i18n( "Enable special bookmarks" ) );
	menu.setCheckable( true );
	
	menu.insertItem( i18n( "Popular URLs" ), POPULAR_URLS_ID );
	menu.setItemChecked( POPULAR_URLS_ID, hasPopularURLs );
	menu.insertItem( i18n( "Devices" ), DEVICES_ID );
	menu.setItemChecked( DEVICES_ID, hasDevices );
	menu.insertItem( i18n( "Local Network" ), LAN_ID );
	menu.setItemChecked( LAN_ID, hasLan );
	menu.insertItem( i18n( "Virtual Filesystem" ), VIRTUAL_FS_ID );
	menu.setItemChecked( VIRTUAL_FS_ID, hasVirtualFS );
	menu.insertItem( i18n( "Jump back" ), JUMP_BACK_ID );
	menu.setItemChecked( JUMP_BACK_ID, hasJumpback );
	
	connect( _mainBookmarkPopup, TQT_SIGNAL( highlighted( int ) ), &menu, TQT_SLOT( close() ) );
	connect( _mainBookmarkPopup, TQT_SIGNAL( activated( int ) ), &menu, TQT_SLOT( close() ) );
	
	int result = menu.exec( TQCursor::pos() );
	bool doCloseMain = true;
	
	krConfig->setGroup( "Private" );
	
	switch( result ) {
	case POPULAR_URLS_ID:
		krConfig->writeEntry( "BM Popular URLs", !hasPopularURLs );
		break;
	case DEVICES_ID:
		krConfig->writeEntry( "BM Devices", !hasDevices );
		break;
	case LAN_ID:
		krConfig->writeEntry( "BM Lan", !hasLan );
		break;
	case VIRTUAL_FS_ID:
		krConfig->writeEntry( "BM Virtual FS", !hasVirtualFS );
		break;
	case JUMP_BACK_ID:
		krConfig->writeEntry( "BM Jumpback", !hasJumpback );
		break;
	default:
		doCloseMain = false;
		break;
	}
	
	menu.close();
	
	if( doCloseMain && _mainBookmarkPopup )
		_mainBookmarkPopup->close();
}

#define OPEN_ID           100200
#define OPEN_NEW_TAB_ID   100201
#define DELETE_ID         100202

void KrBookmarkHandler::rightClicked( TQPopupMenu *menu, int /*id*/, KrBookmark * bm ) {
	TQPopupMenu popup( _mainBookmarkPopup );
	
	popup.insertItem( krLoader->loadIcon( "fileopen", KIcon::Panel ), i18n( "Open" ), OPEN_ID );
	popup.insertItem( krLoader->loadIcon( "tab_new", KIcon::Panel ), i18n( "Open in a new tab" ), OPEN_NEW_TAB_ID );
	popup.insertSeparator();
	popup.insertItem( krLoader->loadIcon( "editdelete", KIcon::Panel ), i18n( "Delete" ), DELETE_ID );
	
	connect( menu, TQT_SIGNAL( highlighted( int ) ), &popup, TQT_SLOT( close() ) );
	connect( menu, TQT_SIGNAL( activated( int ) ), &popup, TQT_SLOT( close() ) );
	
	int result = popup.exec( TQCursor::pos() );
	
	popup.close();
	if( _mainBookmarkPopup && result >= OPEN_ID && result <= DELETE_ID ) {
		_mainBookmarkPopup->close();
	}
	
	switch( result ) {
	case OPEN_ID:
		SLOTS->refresh( bm->url() );
		break;
	case OPEN_NEW_TAB_ID:
		SLOTS->newTab( bm->url() );
		break;
	case DELETE_ID:
		deleteBookmark( bm );
		break;
	}
}

// used to monitor middle clicks. if mid is found, then the
// bookmark is opened in a new tab. ugly, but easier than overloading
// TDEAction and TDEActionCollection.
void KrBookmarkHandler::slotActivated(const KURL& url) {
	if (_middleClick)
		SLOTS->newTab(url);
	else SLOTS->refresh(url);
}


#include "krbookmarkhandler.moc"