• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/bookmarks
 

tdeio/bookmarks

  • tdeio
  • bookmarks
kbookmarkmanager.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>
3 Copyright (C) 2003 Alexander Kellett <lypanov@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kbookmarkmanager.h"
21#include "kbookmarkmenu.h"
22#include "kbookmarkmenu_p.h"
23#include "kbookmarkimporter.h"
24#include <kdebug.h>
25#include <krun.h>
26#include <tdestandarddirs.h>
27#include <ksavefile.h>
28#include <dcopref.h>
29#include <tqregexp.h>
30#include <tdemessagebox.h>
31#include <tdeprocess.h>
32#include <tdelocale.h>
33#include <tdeapplication.h>
34#include <dcopclient.h>
35#include <tqfile.h>
36#include <tqfileinfo.h>
37#include <tqtextstream.h>
38#include <kstaticdeleter.h>
39#include <tqptrstack.h>
40
41#include "dptrtemplate.h"
42
43class KBookmarkManagerPrivate : public dPtrTemplate<KBookmarkManager, KBookmarkManagerPrivate> {
44public:
45 KBookmarkManagerPrivate()
46 { m_browserEditor = true; }
47 TQString m_editorCaption;
48 bool m_browserEditor;
49};
50template<> TQPtrDict<KBookmarkManagerPrivate>* dPtrTemplate<KBookmarkManager, KBookmarkManagerPrivate>::d_ptr = 0;
51
52KBookmarkManagerPrivate* KBookmarkManager::dptr() const {
53 return KBookmarkManagerPrivate::d( this );
54}
55
56// TODO - clean this stuff up by just using the above dptrtemplate?
57TQPtrList<KBookmarkManager>* KBookmarkManager::s_pSelf;
58static KStaticDeleter<TQPtrList<KBookmarkManager> > sdbm;
59
60class KBookmarkMap : private KBookmarkGroupTraverser {
61public:
62 KBookmarkMap( KBookmarkManager * );
63 void update();
64 TQValueList<KBookmark> find( const TQString &url ) const
65 { return m_bk_map[url]; }
66private:
67 virtual void visit(const KBookmark &);
68 virtual void visitEnter(const KBookmarkGroup &) { ; }
69 virtual void visitLeave(const KBookmarkGroup &) { ; }
70private:
71 typedef TQValueList<KBookmark> KBookmarkList;
72 TQMap<TQString, KBookmarkList> m_bk_map;
73 KBookmarkManager *m_manager;
74};
75
76static KBookmarkMap *s_bk_map = 0;
77
78KBookmarkMap::KBookmarkMap( KBookmarkManager *manager ) {
79 m_manager = manager;
80}
81
82void KBookmarkMap::update()
83{
84 m_bk_map.clear();
85 KBookmarkGroup root = m_manager->root();
86 traverse(root);
87}
88
89void KBookmarkMap::visit(const KBookmark &bk)
90{
91 if (!bk.isSeparator()) {
92 // add bookmark to url map
93 m_bk_map[bk.internalElement().attribute("href")].append(bk);
94 }
95}
96
97
98KBookmarkManager* KBookmarkManager::managerForFile( const TQString& bookmarksFile, bool bImportDesktopFiles )
99{
100 if ( !s_pSelf ) {
101 sdbm.setObject( s_pSelf, new TQPtrList<KBookmarkManager> );
102 s_pSelf->setAutoDelete( true );
103 }
104 TQPtrListIterator<KBookmarkManager> it ( *s_pSelf );
105 for ( ; it.current() ; ++it )
106 if ( it.current()->path() == bookmarksFile )
107 return it.current();
108
109 KBookmarkManager* mgr = new KBookmarkManager( bookmarksFile, bImportDesktopFiles );
110 s_pSelf->append( mgr );
111 return mgr;
112}
113
114// principally used for filtered toolbars
115KBookmarkManager* KBookmarkManager::createTempManager()
116{
117 if ( !s_pSelf ) {
118 sdbm.setObject( s_pSelf, new TQPtrList<KBookmarkManager> );
119 s_pSelf->setAutoDelete( true );
120 }
121 KBookmarkManager* mgr = new KBookmarkManager();
122 s_pSelf->append( mgr );
123 return mgr;
124}
125
126#define PI_DATA "version=\"1.0\" encoding=\"UTF-8\""
127
128KBookmarkManager::KBookmarkManager( const TQString & bookmarksFile, bool bImportDesktopFiles )
129 : DCOPObject(TQCString("KBookmarkManager-")+bookmarksFile.utf8()), m_doc("xbel"), m_docIsLoaded(false)
130{
131 m_toolbarDoc.clear();
132
133 m_update = true;
134 m_showNSBookmarks = true;
135
136 Q_ASSERT( !bookmarksFile.isEmpty() );
137 m_bookmarksFile = bookmarksFile;
138
139 if ( !TQFile::exists(m_bookmarksFile) )
140 {
141 TQDomElement topLevel = m_doc.createElement("xbel");
142 m_doc.appendChild( topLevel );
143 m_doc.insertBefore( m_doc.createProcessingInstruction( "xml", PI_DATA), topLevel );
144 if ( bImportDesktopFiles )
145 importDesktopFiles();
146 m_docIsLoaded = true;
147 }
148
149 connectDCOPSignal(0, objId(), "bookmarksChanged(TQString)", "notifyChanged(TQString)", false);
150 connectDCOPSignal(0, objId(), "bookmarkConfigChanged()", "notifyConfigChanged()", false);
151}
152
153KBookmarkManager::KBookmarkManager( )
154 : DCOPObject(TQCString("KBookmarkManager-generated")), m_doc("xbel"), m_docIsLoaded(true)
155{
156 m_toolbarDoc.clear(); // strange ;-)
157
158 m_update = false; // TODO - make it read/write
159 m_showNSBookmarks = true;
160
161 m_bookmarksFile = TQString::null; // AK - check all codepaths for this one
162
163 TQDomElement topLevel = m_doc.createElement("xbel");
164 m_doc.appendChild( topLevel );
165 m_doc.insertBefore( m_doc.createProcessingInstruction( "xml", PI_DATA), topLevel );
166
167 // TODO - enable this via some sort of api and fix the above DCOPObject script somehow
168#if 0
169 connectDCOPSignal(0, objId(), "bookmarksChanged(TQString)", "notifyChanged(TQString)", false);
170 connectDCOPSignal(0, objId(), "bookmarkConfigChanged()", "notifyConfigChanged()", false);
171#endif
172}
173
174KBookmarkManager::~KBookmarkManager()
175{
176 if ( s_pSelf )
177 s_pSelf->removeRef( this );
178}
179
180void KBookmarkManager::setUpdate( bool update )
181{
182 m_update = update;
183}
184
185const TQDomDocument &KBookmarkManager::internalDocument() const
186{
187 if(!m_docIsLoaded)
188 {
189 parse();
190 m_toolbarDoc.clear();
191 }
192 return m_doc;
193}
194
195
196void KBookmarkManager::parse() const
197{
198 m_docIsLoaded = true;
199 //kdDebug(7043) << "KBookmarkManager::parse " << m_bookmarksFile << endl;
200 TQFile file( m_bookmarksFile );
201 if ( !file.open( IO_ReadOnly ) )
202 {
203 kdWarning() << "Can't open " << m_bookmarksFile << endl;
204 return;
205 }
206 m_doc = TQDomDocument("xbel");
207 m_doc.setContent( &file );
208
209 TQDomElement docElem = m_doc.documentElement();
210 if ( docElem.isNull() )
211 kdWarning() << "KBookmarkManager::parse : can't parse " << m_bookmarksFile << endl;
212 else
213 {
214 TQString mainTag = docElem.tagName();
215 if ( mainTag == "BOOKMARKS" )
216 {
217 kdWarning() << "Old style bookmarks found. Calling convertToXBEL." << endl;
218 docElem.setTagName("xbel");
219 if ( docElem.hasAttribute( "HIDE_NSBK" ) && m_showNSBookmarks ) // non standard either, but we need it
220 {
221 docElem.setAttribute( "hide_nsbk", docElem.attribute( "HIDE_NSBK" ) == "1" ? "yes" : "no" );
222 docElem.removeAttribute( "HIDE_NSBK" );
223 }
224
225 convertToXBEL( docElem );
226 save();
227 }
228 else if ( mainTag != "xbel" )
229 kdWarning() << "KBookmarkManager::parse : unknown main tag " << mainTag << endl;
230
231 TQDomNode n = m_doc.documentElement().previousSibling();
232 if ( n.isProcessingInstruction() )
233 {
234 TQDomProcessingInstruction pi = n.toProcessingInstruction();
235 pi.parentNode().removeChild(pi);
236 }
237
238 TQDomProcessingInstruction pi;
239 pi = m_doc.createProcessingInstruction( "xml", PI_DATA );
240 m_doc.insertBefore( pi, docElem );
241 }
242
243 file.close();
244 if ( !s_bk_map )
245 s_bk_map = new KBookmarkMap( const_cast<KBookmarkManager*>( this ) );
246 s_bk_map->update();
247}
248
249void KBookmarkManager::convertToXBEL( TQDomElement & group )
250{
251 TQDomNode n = group.firstChild();
252 while( !n.isNull() )
253 {
254 TQDomElement e = n.toElement();
255 if ( !e.isNull() )
256 {
257 if ( e.tagName() == "TEXT" )
258 {
259 e.setTagName("title");
260 }
261 else if ( e.tagName() == "SEPARATOR" )
262 {
263 e.setTagName("separator"); // so close...
264 }
265 else if ( e.tagName() == "GROUP" )
266 {
267 e.setTagName("folder");
268 convertAttribute(e, "ICON","icon"); // non standard, but we need it
269 if ( e.hasAttribute( "TOOLBAR" ) ) // non standard either, but we need it
270 {
271 e.setAttribute( "toolbar", e.attribute( "TOOLBAR" ) == "1" ? "yes" : "no" );
272 e.removeAttribute( "TOOLBAR" );
273 }
274
275 convertAttribute(e, "NETSCAPEINFO","netscapeinfo"); // idem
276 bool open = (e.attribute("OPEN") == "1");
277 e.removeAttribute("OPEN");
278 e.setAttribute("folded", open ? "no" : "yes");
279 convertToXBEL( e );
280 }
281 else
282 {
283 if ( e.tagName() == "BOOKMARK" )
284 {
285 e.setTagName("bookmark"); // so much difference :-)
286 convertAttribute(e, "ICON","icon"); // non standard, but we need it
287 convertAttribute(e, "NETSCAPEINFO","netscapeinfo"); // idem
288 convertAttribute(e, "URL","href");
289 TQString text = e.text();
290 while ( !e.firstChild().isNull() ) // clean up the old contained text
291 e.removeChild(e.firstChild());
292 TQDomElement titleElem = e.ownerDocument().createElement("title");
293 e.appendChild( titleElem ); // should be the only child anyway
294 titleElem.appendChild( e.ownerDocument().createTextNode( text ) );
295 }
296 else
297 {
298 kdWarning(7043) << "Unknown tag " << e.tagName() << endl;
299 }
300 }
301 }
302 n = n.nextSibling();
303 }
304}
305
306void KBookmarkManager::convertAttribute( TQDomElement elem, const TQString & oldName, const TQString & newName )
307{
308 if ( elem.hasAttribute( oldName ) )
309 {
310 elem.setAttribute( newName, elem.attribute( oldName ) );
311 elem.removeAttribute( oldName );
312 }
313}
314
315void KBookmarkManager::importDesktopFiles()
316{
317 KBookmarkImporter importer( const_cast<TQDomDocument *>(&internalDocument()) );
318 TQString path(TDEGlobal::dirs()->saveLocation("data", "kfm/bookmarks", true));
319 importer.import( path );
320 //kdDebug(7043) << internalDocument().toCString() << endl;
321
322 save();
323}
324
325bool KBookmarkManager::save( bool toolbarCache ) const
326{
327 return saveAs( m_bookmarksFile, toolbarCache );
328}
329
330bool KBookmarkManager::saveAs( const TQString & filename, bool toolbarCache ) const
331{
332 kdDebug(7043) << "KBookmarkManager::save " << filename << endl;
333
334 // Save the bookmark toolbar folder for quick loading
335 // but only when it will actually make things quicker
336 const TQString cacheFilename = filename + TQString::fromLatin1(".tbcache");
337 if(toolbarCache && !root().isToolbarGroup())
338 {
339 KSaveFile cacheFile( cacheFilename );
340 if ( cacheFile.status() == 0 )
341 {
342 TQString str;
343 TQTextStream stream(&str, IO_WriteOnly);
344 stream << root().findToolbar();
345 TQCString cstr = str.utf8();
346 cacheFile.file()->writeBlock( cstr.data(), cstr.length() );
347 cacheFile.close();
348 }
349 }
350 else // remove any (now) stale cache
351 {
352 TQFile::remove( cacheFilename );
353 }
354
355 KSaveFile file( filename );
356 if ( file.status() == 0 )
357 {
358 file.backupFile( file.name(), TQString::null, ".bak" );
359 TQCString cstr;
360 cstr = internalDocument().toCString(); // is in UTF8
361 file.file()->writeBlock( cstr.data(), cstr.length() );
362 if ( file.close() )
363 return true;
364 }
365
366 static int hadSaveError = false;
367 file.abort();
368 if ( !hadSaveError ) {
369 TQString error = i18n("Unable to save bookmarks in %1. Reported error was: %2. "
370 "This error message will only be shown once. The cause "
371 "of the error needs to be fixed as quickly as possible, "
372 "which is most likely a full hard drive.")
373 .arg(filename).arg(TQString::fromLocal8Bit(strerror(file.status())));
374 if (tqApp->type() != TQApplication::Tty)
375 KMessageBox::error( 0L, error );
376 else
377 kdError() << error << endl;
378 }
379 hadSaveError = true;
380 return false;
381}
382
383KBookmarkGroup KBookmarkManager::root() const
384{
385 return KBookmarkGroup(internalDocument().documentElement());
386}
387
388KBookmarkGroup KBookmarkManager::toolbar()
389{
390 kdDebug(7043) << "KBookmarkManager::toolbar begin" << endl;
391 // Only try to read from a toolbar cache if the full document isn't loaded
392 if(!m_docIsLoaded)
393 {
394 kdDebug(7043) << "KBookmarkManager::toolbar trying cache" << endl;
395 const TQString cacheFilename = m_bookmarksFile + TQString::fromLatin1(".tbcache");
396 TQFileInfo bmInfo(m_bookmarksFile);
397 TQFileInfo cacheInfo(cacheFilename);
398 if (m_toolbarDoc.isNull() &&
399 TQFile::exists(cacheFilename) &&
400 bmInfo.lastModified() < cacheInfo.lastModified())
401 {
402 kdDebug(7043) << "KBookmarkManager::toolbar reading file" << endl;
403 TQFile file( cacheFilename );
404
405 if ( file.open( IO_ReadOnly ) )
406 {
407 m_toolbarDoc = TQDomDocument("cache");
408 m_toolbarDoc.setContent( &file );
409 kdDebug(7043) << "KBookmarkManager::toolbar opened" << endl;
410 }
411 }
412 if (!m_toolbarDoc.isNull())
413 {
414 kdDebug(7043) << "KBookmarkManager::toolbar returning element" << endl;
415 TQDomElement elem = m_toolbarDoc.firstChild().toElement();
416 return KBookmarkGroup(elem);
417 }
418 }
419
420 // Fallback to the normal way if there is no cache or if the bookmark file
421 // is already loaded
422 TQDomElement elem = root().findToolbar();
423 if (elem.isNull())
424 return root(); // Root is the bookmark toolbar if none has been set.
425 else
426 return KBookmarkGroup(root().findToolbar());
427}
428
429KBookmark KBookmarkManager::findByAddress( const TQString & address, bool tolerant )
430{
431 //kdDebug(7043) << "KBookmarkManager::findByAddress " << address << endl;
432 KBookmark result = root();
433 // The address is something like /5/10/2+
434 TQStringList addresses = TQStringList::split(TQRegExp("[/+]"),address);
435 // kdWarning() << addresses.join(",") << endl;
436 for ( TQStringList::Iterator it = addresses.begin() ; it != addresses.end() ; )
437 {
438 bool append = ((*it) == "+");
439 uint number = (*it).toUInt();
440 Q_ASSERT(result.isGroup());
441 KBookmarkGroup group = result.toGroup();
442 KBookmark bk = group.first(), lbk = bk; // last non-null bookmark
443 for ( uint i = 0 ; ( (i<number) || append ) && !bk.isNull() ; ++i ) {
444 lbk = bk;
445 bk = group.next(bk);
446 //kdWarning() << i << endl;
447 }
448 it++;
449 int shouldBeGroup = !bk.isGroup() && (it != addresses.end());
450 if ( tolerant && ( bk.isNull() || shouldBeGroup ) ) {
451 if (!lbk.isNull()) result = lbk;
452 //kdWarning() << "break" << endl;
453 break;
454 }
455 //kdWarning() << "found section" << endl;
456 result = bk;
457 }
458 if (result.isNull()) {
459 kdWarning() << "KBookmarkManager::findByAddress: couldn't find item " << address << endl;
460 Q_ASSERT(!tolerant);
461 }
462 //kdWarning() << "found " << result.address() << endl;
463 return result;
464 }
465
466static TQString pickUnusedTitle( KBookmarkGroup parentBookmark,
467 const TQString &title, const TQString &url
468) {
469 // If this title is already used, we'll try to find something unused.
470 KBookmark ch = parentBookmark.first();
471 int count = 1;
472 TQString uniqueTitle = title;
473 do
474 {
475 while ( !ch.isNull() )
476 {
477 if ( uniqueTitle == ch.text() )
478 {
479 // Title already used !
480 if ( url != ch.url().url() )
481 {
482 uniqueTitle = title + TQString(" (%1)").arg(++count);
483 // New title -> restart search from the beginning
484 ch = parentBookmark.first();
485 break;
486 }
487 else
488 {
489 // this exact URL already exists
490 return TQString::null;
491 }
492 }
493 ch = parentBookmark.next( ch );
494 }
495 } while ( !ch.isNull() );
496
497 return uniqueTitle;
498}
499
500KBookmarkGroup KBookmarkManager::addBookmarkDialog(
501 const TQString & _url, const TQString & _title,
502 const TQString & _parentBookmarkAddress
503) {
504 TQString url = _url;
505 TQString title = _title;
506 TQString parentBookmarkAddress = _parentBookmarkAddress;
507
508 if ( url.isEmpty() )
509 {
510 KMessageBox::error( 0L, i18n("Cannot add bookmark with empty URL."));
511 return KBookmarkGroup();
512 }
513
514 if ( title.isEmpty() )
515 title = url;
516
517 if ( KBookmarkSettings::self()->m_advancedaddbookmark)
518 {
519 KBookmarkEditDialog dlg( title, url, this, KBookmarkEditDialog::InsertionMode, parentBookmarkAddress );
520 if ( dlg.exec() != KDialogBase::Accepted )
521 return KBookmarkGroup();
522 title = dlg.finalTitle();
523 url = dlg.finalUrl();
524 parentBookmarkAddress = dlg.finalAddress();
525 }
526
527 KBookmarkGroup parentBookmark;
528 parentBookmark = findByAddress( parentBookmarkAddress ).toGroup();
529 Q_ASSERT( !parentBookmark.isNull() );
530
531 TQString uniqueTitle = pickUnusedTitle( parentBookmark, title, url );
532 if ( !uniqueTitle.isNull() )
533 parentBookmark.addBookmark( this, uniqueTitle, KURL( url ));
534
535 return parentBookmark;
536}
537
538
539void KBookmarkManager::emitChanged( /*KDE4 const*/ KBookmarkGroup & group )
540{
541 save();
542
543 // Tell the other processes too
544 // kdDebug(7043) << "KBookmarkManager::emitChanged : broadcasting change " << group.address() << endl;
545
546 TQByteArray data;
547 TQDataStream ds( data, IO_WriteOnly );
548 ds << group.address();
549
550 emitDCOPSignal("bookmarksChanged(TQString)", data);
551
552 // We do get our own broadcast, so no need for this anymore
553 //emit changed( group );
554}
555
556void KBookmarkManager::emitConfigChanged()
557{
558 emitDCOPSignal("bookmarkConfigChanged()", TQByteArray());
559}
560
561void KBookmarkManager::notifyCompleteChange( TQString caller ) // DCOP call
562{
563 if (!m_update) return;
564
565 //kdDebug(7043) << "KBookmarkManager::notifyCompleteChange" << endl;
566 // The bk editor tells us we should reload everything
567 // Reparse
568 parse();
569 // Tell our GUI
570 // (emit where group is "" to directly mark the root menu as dirty)
571 emit changed( "", caller );
572}
573
574void KBookmarkManager::notifyConfigChanged() // DCOP call
575{
576 kdDebug() << "reloaded bookmark config!" << endl;
577 KBookmarkSettings::self()->readSettings();
578 parse(); // reload, and thusly recreate the menus
579}
580
581void KBookmarkManager::notifyChanged( TQString groupAddress ) // DCOP call
582{
583 if (!m_update) return;
584
585 // Reparse (the whole file, no other choice)
586 // if someone else notified us
587 if (callingDcopClient()->senderId() != DCOPClient::mainClient()->appId())
588 parse();
589
590 //kdDebug(7043) << "KBookmarkManager::notifyChanged " << groupAddress << endl;
591 //KBookmarkGroup group = findByAddress( groupAddress ).toGroup();
592 //Q_ASSERT(!group.isNull());
593 emit changed( groupAddress, TQString::null );
594}
595
596bool KBookmarkManager::showNSBookmarks() const
597{
598 return KBookmarkMenu::showDynamicBookmarks("netscape").show;
599}
600
601void KBookmarkManager::setShowNSBookmarks( bool show )
602{
603 m_showNSBookmarks = show;
604 if (this->path() != userBookmarksFile())
605 return;
606 KBookmarkMenu::DynMenuInfo info
607 = KBookmarkMenu::showDynamicBookmarks("netscape");
608 info.show = show;
609 KBookmarkMenu::setDynamicBookmarks("netscape", info);
610}
611
612void KBookmarkManager::setEditorOptions( const TQString& caption, bool browser )
613{
614 dptr()->m_editorCaption = caption;
615 dptr()->m_browserEditor = browser;
616}
617
618void KBookmarkManager::slotEditBookmarks()
619{
620 TDEProcess proc;
621 proc << TQString::fromLatin1("keditbookmarks");
622 if (!dptr()->m_editorCaption.isNull())
623 proc << TQString::fromLatin1("--customcaption") << dptr()->m_editorCaption;
624 if (!dptr()->m_browserEditor)
625 proc << TQString::fromLatin1("--nobrowser");
626 proc << m_bookmarksFile;
627 proc.start(TDEProcess::DontCare);
628}
629
630void KBookmarkManager::slotEditBookmarksAtAddress( const TQString& address )
631{
632 TDEProcess proc;
633 proc << TQString::fromLatin1("keditbookmarks")
634 << TQString::fromLatin1("--address") << address
635 << m_bookmarksFile;
636 proc.start(TDEProcess::DontCare);
637}
638
640
641void KBookmarkOwner::openBookmarkURL( const TQString& url )
642{
643 (void) new KRun(KURL( url ));
644}
645
646void KBookmarkOwner::virtual_hook( int, void* )
647{ /*BASE::virtual_hook( id, data );*/ }
648
649bool KBookmarkManager::updateAccessMetadata( const TQString & url, bool emitSignal )
650{
651 if (!s_bk_map) {
652 s_bk_map = new KBookmarkMap(this);
653 s_bk_map->update();
654 }
655
656 TQValueList<KBookmark> list = s_bk_map->find(url);
657 if ( list.count() == 0 )
658 return false;
659
660 for ( TQValueList<KBookmark>::iterator it = list.begin();
661 it != list.end(); ++it )
662 (*it).updateAccessMetadata();
663
664 if (emitSignal)
665 emit notifier().updatedAccessMetadata( path(), url );
666
667 return true;
668}
669
670void KBookmarkManager::updateFavicon( const TQString &url, const TQString &faviconurl, bool emitSignal )
671{
672 Q_UNUSED(faviconurl);
673
674 if (!s_bk_map) {
675 s_bk_map = new KBookmarkMap(this);
676 s_bk_map->update();
677 }
678
679 TQValueList<KBookmark> list = s_bk_map->find(url);
680 for ( TQValueList<KBookmark>::iterator it = list.begin();
681 it != list.end(); ++it )
682 {
683 // TODO - update favicon data based on faviconurl
684 // but only when the previously used icon
685 // isn't a manually set one.
686 }
687
688 if (emitSignal)
689 {
690 // TODO
691 // emit notifier().updatedFavicon( path(), url, faviconurl );
692 }
693}
694
695TQString KBookmarkManager::userBookmarksFile()
696{
697 return locateLocal("data", TQString::fromLatin1("konqueror/bookmarks.xml"));
698}
699
700KBookmarkManager* KBookmarkManager::userBookmarksManager()
701{
702 return KBookmarkManager::managerForFile( userBookmarksFile() );
703}
704
705KBookmarkSettings* KBookmarkSettings::s_self = 0;
706
707void KBookmarkSettings::readSettings()
708{
709 TDEConfig config("kbookmarkrc", false, false);
710 config.setGroup("Bookmarks");
711
712 // add bookmark dialog usage - no reparse
713 s_self->m_advancedaddbookmark = config.readBoolEntry("AdvancedAddBookmarkDialog", false);
714
715 // these three alter the menu, therefore all need a reparse
716 s_self->m_contextmenu = config.readBoolEntry("ContextMenuActions", true);
717 s_self->m_quickactions = config.readBoolEntry("QuickActionSubmenu", false);
718 s_self->m_filteredtoolbar = config.readBoolEntry("FilteredToolbar", false);
719}
720
721KBookmarkSettings *KBookmarkSettings::self()
722{
723 if (!s_self)
724 {
725 s_self = new KBookmarkSettings;
726 readSettings();
727 }
728 return s_self;
729}
730
731#include "kbookmarkmanager.moc"
KBookmarkGroupTraverser
Definition: kbookmark.h:316
KBookmarkGroup
A group of bookmarks.
Definition: kbookmark.h:198
KBookmarkGroup::next
KBookmark next(const KBookmark &current) const
Return the next sibling of a child bookmark of this group.
Definition: kbookmark.cpp:81
KBookmarkGroup::first
KBookmark first() const
Return the first child bookmark of this group.
Definition: kbookmark.cpp:71
KBookmarkGroup::addBookmark
KBookmark addBookmark(KBookmarkManager *mgr, const KBookmark &bm, bool emitSignal=true)
Create a new bookmark, as the last child of this group Don't forget to use KBookmarkManager::self()->...
Definition: kbookmark.cpp:176
KBookmarkImporter
A class for importing the previous bookmarks (desktop files) Separated from KBookmarkManager to save ...
Definition: kbookmarkimporter_kde1.h:33
KBookmarkManager
This class implements the reading/writing of bookmarks in XML.
Definition: kbookmarkmanager.h:52
KBookmarkManager::emitChanged
void emitChanged(KBookmarkGroup &group)
Saves the bookmark file and notifies everyone.
Definition: kbookmarkmanager.cpp:539
KBookmarkManager::path
TQString path()
This will return the path that this manager is using to read the bookmarks.
Definition: kbookmarkmanager.h:132
KBookmarkManager::findByAddress
KBookmark findByAddress(const TQString &address, bool tolerate=false)
Definition: kbookmarkmanager.cpp:429
KBookmarkManager::notifyChanged
ASYNC notifyChanged(TQString groupAddress)
Emit the changed signal for the group whose address is given.
Definition: kbookmarkmanager.cpp:581
KBookmarkManager::notifier
KBookmarkNotifier & notifier()
Access to bookmark notifier, for emitting signals.
Definition: kbookmarkmanager.h:235
KBookmarkManager::toolbar
KBookmarkGroup toolbar()
This returns the root of the toolbar menu.
Definition: kbookmarkmanager.cpp:388
KBookmarkManager::saveAs
bool saveAs(const TQString &filename, bool toolbarCache=true) const
Save the bookmarks to the given XML file on disk.
Definition: kbookmarkmanager.cpp:330
KBookmarkManager::setEditorOptions
void setEditorOptions(const TQString &caption, bool browser)
Set options with which slotEditBookmarks called keditbookmarks this can be used to change the appeara...
Definition: kbookmarkmanager.cpp:612
KBookmarkManager::setUpdate
void setUpdate(bool update)
Set the update flag.
Definition: kbookmarkmanager.cpp:180
KBookmarkManager::addBookmarkDialog
KBookmarkGroup addBookmarkDialog(const TQString &_url, const TQString &_title, const TQString &_parentBookmarkAddress=TQString::null)
Definition: kbookmarkmanager.cpp:500
KBookmarkManager::userBookmarksManager
static KBookmarkManager * userBookmarksManager()
Returns a pointer to the users main bookmark collection.
Definition: kbookmarkmanager.cpp:700
KBookmarkManager::save
bool save(bool toolbarCache=true) const
Save the bookmarks to the default konqueror XML file on disk.
Definition: kbookmarkmanager.cpp:325
KBookmarkManager::root
KBookmarkGroup root() const
This will return the root bookmark.
Definition: kbookmarkmanager.cpp:383
KBookmarkManager::showNSBookmarks
bool showNSBookmarks() const
Definition: kbookmarkmanager.cpp:596
KBookmarkManager::changed
void changed(const TQString &groupAddress, const TQString &caller)
Signals that the group (or any of its children) with the address groupAddress (e.g.
KBookmarkManager::~KBookmarkManager
~KBookmarkManager()
Destructor.
Definition: kbookmarkmanager.cpp:174
KBookmarkManager::notifyCompleteChange
ASYNC notifyCompleteChange(TQString caller)
Reparse the whole bookmarks file and notify about the change (Called by the bookmark editor)
Definition: kbookmarkmanager.cpp:561
KBookmarkManager::managerForFile
static KBookmarkManager * managerForFile(const TQString &bookmarksFile, bool bImportDesktopFiles=true)
This static function will return an instance of the KBookmarkManager, responsible for the given bookm...
Definition: kbookmarkmanager.cpp:98
KBookmarkManager::KBookmarkManager
KBookmarkManager()
Definition: kbookmarkmanager.cpp:153
KBookmarkManager::userBookmarksFile
static TQString userBookmarksFile()
Returns the path to the user's main bookmark collection file.
Definition: kbookmarkmanager.cpp:695
KBookmarkManager::setShowNSBookmarks
void setShowNSBookmarks(bool show)
Shows an extra menu for NS bookmarks.
Definition: kbookmarkmanager.cpp:601
KBookmarkManager::updateAccessMetadata
bool updateAccessMetadata(const TQString &url, bool emitSignal=true)
Update access time stamps for a given url.
Definition: kbookmarkmanager.cpp:649
KBookmarkMenu::showDynamicBookmarks
static DynMenuInfo showDynamicBookmarks(const TQString &id)
Definition: kbookmarkmenu.cpp:1098
KBookmarkMenu::setDynamicBookmarks
static void setDynamicBookmarks(const TQString &id, const DynMenuInfo &info)
Shows an extra menu for the given bookmarks file and type.
Definition: kbookmarkmenu.cpp:1144
KBookmarkOwner::openBookmarkURL
virtual void openBookmarkURL(const TQString &_url)
This function is called if the user selects a bookmark.
Definition: kbookmarkmanager.cpp:641
KBookmarkMenu::DynMenuInfo
Structure used for storing information about the dynamic menu setting.
Definition: kbookmarkmenu.h:128

tdeio/bookmarks

Skip menu "tdeio/bookmarks"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/bookmarks

Skip menu "tdeio/bookmarks"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/bookmarks by doxygen 1.9.4
This website is maintained by Timothy Pearson.