• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • bookmarks
kbookmarkmanager.cc
Go to the documentation of this file.
1// -*- c-basic-offset:4; indent-tabs-mode:nil -*-
2// vim: set ts=4 sts=4 sw=4 et:
3/* This file is part of the KDE libraries
4 Copyright (C) 2000 David Faure <faure@kde.org>
5 Copyright (C) 2003 Alexander Kellett <lypanov@kde.org>
6 Copyright (C) 2008 Norbert Frese <nf2@scheinwelt.at>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License version 2 as published by the Free Software Foundation.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#include "kbookmarkmanager.h"
24
25#include <QtCore/QFile>
26#include <QtCore/QFileInfo>
27#include <QtCore/QProcess>
28#include <QtCore/QRegExp>
29#include <QtCore/QTextStream>
30#include <QtDBus/QtDBus>
31#include <QtGui/QApplication>
32
33#include <kconfiggroup.h>
34#include <kdebug.h>
35#include <kdirwatch.h>
36#include <klocale.h>
37#include <kmessagebox.h>
38#include <ksavefile.h>
39#include <kstandarddirs.h>
40
41#include "kbookmarkmenu.h"
42#include "kbookmarkmenu_p.h"
43#include "kbookmarkimporter.h"
44#include "kbookmarkdialog.h"
45#include "kbookmarkmanageradaptor_p.h"
46
47#define BOOKMARK_CHANGE_NOTIFY_INTERFACE "org.kde.KIO.KBookmarkManager"
48
49class KBookmarkManagerList : public QList<KBookmarkManager *>
50{
51public:
52 ~KBookmarkManagerList() {
53 qDeleteAll( begin() , end() ); // auto-delete functionality
54 }
55
56 QReadWriteLock lock;
57};
58
59K_GLOBAL_STATIC(KBookmarkManagerList, s_pSelf)
60
61class KBookmarkMap : private KBookmarkGroupTraverser {
62public:
63 KBookmarkMap() : m_mapNeedsUpdate(true) {}
64 void setNeedsUpdate() { m_mapNeedsUpdate = true; }
65 void update(KBookmarkManager*);
66 QList<KBookmark> find( const QString &url ) const
67 { return m_bk_map.value(url); }
68private:
69 virtual void visit(const KBookmark &);
70 virtual void visitEnter(const KBookmarkGroup &) { ; }
71 virtual void visitLeave(const KBookmarkGroup &) { ; }
72private:
73 typedef QList<KBookmark> KBookmarkList;
74 QMap<QString, KBookmarkList> m_bk_map;
75 bool m_mapNeedsUpdate;
76};
77
78void KBookmarkMap::update(KBookmarkManager *manager)
79{
80 if (m_mapNeedsUpdate) {
81 m_mapNeedsUpdate = false;
82
83 m_bk_map.clear();
84 KBookmarkGroup root = manager->root();
85 traverse(root);
86 }
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// #########################
98// KBookmarkManager::Private
99class KBookmarkManager::Private
100{
101public:
102 Private(bool bDocIsloaded, const QString &dbusObjectName = QString())
103 : m_doc("xbel")
104 , m_dbusObjectName(dbusObjectName)
105 , m_docIsLoaded(bDocIsloaded)
106 , m_update(false)
107 , m_dialogAllowed(true)
108 , m_dialogParent(0)
109 , m_browserEditor(false)
110 , m_typeExternal(false)
111 , m_kDirWatch(0)
112 {}
113
114 ~Private() {
115 delete m_kDirWatch;
116 }
117
118 mutable QDomDocument m_doc;
119 mutable QDomDocument m_toolbarDoc;
120 QString m_bookmarksFile;
121 QString m_dbusObjectName;
122 mutable bool m_docIsLoaded;
123 bool m_update;
124 bool m_dialogAllowed;
125 QWidget *m_dialogParent;
126
127 bool m_browserEditor;
128 QString m_editorCaption;
129
130 bool m_typeExternal;
131 KDirWatch * m_kDirWatch; // for external bookmark files
132
133 KBookmarkMap m_map;
134};
135
136// ################
137// KBookmarkManager
138
139static KBookmarkManager* lookupExisting(const QString& bookmarksFile)
140{
141 for ( KBookmarkManagerList::ConstIterator bmit = s_pSelf->constBegin(), bmend = s_pSelf->constEnd();
142 bmit != bmend; ++bmit ) {
143 if ( (*bmit)->path() == bookmarksFile )
144 return *bmit;
145 }
146 return 0;
147}
148
149
150KBookmarkManager* KBookmarkManager::managerForFile( const QString& bookmarksFile, const QString& dbusObjectName )
151{
152 KBookmarkManager* mgr(0);
153 {
154 QReadLocker readLock(&s_pSelf->lock);
155 mgr = lookupExisting(bookmarksFile);
156 if (mgr) {
157 return mgr;
158 }
159 }
160
161 QWriteLocker writeLock(&s_pSelf->lock);
162 mgr = lookupExisting(bookmarksFile);
163 if (mgr) {
164 return mgr;
165 }
166
167 mgr = new KBookmarkManager( bookmarksFile, dbusObjectName );
168 s_pSelf->append( mgr );
169 return mgr;
170}
171
172KBookmarkManager* KBookmarkManager::managerForExternalFile( const QString& bookmarksFile )
173{
174 KBookmarkManager* mgr(0);
175 {
176 QReadLocker readLock(&s_pSelf->lock);
177 mgr = lookupExisting(bookmarksFile);
178 if (mgr) {
179 return mgr;
180 }
181 }
182
183 QWriteLocker writeLock(&s_pSelf->lock);
184 mgr = lookupExisting(bookmarksFile);
185 if (mgr) {
186 return mgr;
187 }
188
189 mgr = new KBookmarkManager( bookmarksFile );
190 s_pSelf->append( mgr );
191 return mgr;
192}
193
194
195// principally used for filtered toolbars
196KBookmarkManager* KBookmarkManager::createTempManager()
197{
198 KBookmarkManager* mgr = new KBookmarkManager();
199 s_pSelf->append( mgr );
200 return mgr;
201}
202
203#define PI_DATA "version=\"1.0\" encoding=\"UTF-8\""
204
205static QDomElement createXbelTopLevelElement(QDomDocument & doc)
206{
207 QDomElement topLevel = doc.createElement("xbel");
208 topLevel.setAttribute("xmlns:mime", "http://www.freedesktop.org/standards/shared-mime-info");
209 topLevel.setAttribute("xmlns:bookmark", "http://www.freedesktop.org/standards/desktop-bookmarks");
210 topLevel.setAttribute("xmlns:kdepriv", "http://www.kde.org/kdepriv");
211 doc.appendChild( topLevel );
212 doc.insertBefore( doc.createProcessingInstruction( "xml", PI_DATA), topLevel );
213 return topLevel;
214}
215
216KBookmarkManager::KBookmarkManager( const QString & bookmarksFile, const QString & dbusObjectName)
217 : d(new Private(false, dbusObjectName))
218{
219 if(dbusObjectName.isNull()) // get dbusObjectName from file
220 if ( QFile::exists(d->m_bookmarksFile) )
221 parse(); //sets d->m_dbusObjectName
222
223 init( "/KBookmarkManager/"+d->m_dbusObjectName );
224
225 d->m_update = true;
226
227 Q_ASSERT( !bookmarksFile.isEmpty() );
228 d->m_bookmarksFile = bookmarksFile;
229
230 if ( !QFile::exists(d->m_bookmarksFile) )
231 {
232 QDomElement topLevel = createXbelTopLevelElement(d->m_doc);
233 topLevel.setAttribute("dbusName", dbusObjectName);
234 d->m_docIsLoaded = true;
235 }
236}
237
238KBookmarkManager::KBookmarkManager(const QString & bookmarksFile)
239 : d(new Private(false))
240{
241 // use KDirWatch to monitor this bookmarks file
242 d->m_typeExternal = true;
243 d->m_update = true;
244
245 Q_ASSERT( !bookmarksFile.isEmpty() );
246 d->m_bookmarksFile = bookmarksFile;
247
248 if ( !QFile::exists(d->m_bookmarksFile) )
249 {
250 createXbelTopLevelElement(d->m_doc);
251 }
252 else
253 {
254 parse();
255 }
256 d->m_docIsLoaded = true;
257
258 // start KDirWatch
259 d->m_kDirWatch = new KDirWatch;
260 d->m_kDirWatch->addFile(d->m_bookmarksFile);
261 QObject::connect( d->m_kDirWatch, SIGNAL(dirty(const QString&)),
262 this, SLOT(slotFileChanged(const QString&)));
263 QObject::connect( d->m_kDirWatch, SIGNAL(created(const QString&)),
264 this, SLOT(slotFileChanged(const QString&)));
265 QObject::connect( d->m_kDirWatch, SIGNAL(deleted(const QString&)),
266 this, SLOT(slotFileChanged(const QString&)));
267 kDebug(7043) << "starting KDirWatch for " << d->m_bookmarksFile;
268}
269
270KBookmarkManager::KBookmarkManager( )
271 : d(new Private(true))
272{
273 init( "/KBookmarkManager/generated" );
274 d->m_update = false; // TODO - make it read/write
275
276 createXbelTopLevelElement(d->m_doc);
277}
278
279void KBookmarkManager::init( const QString& dbusPath )
280{
281 // A KBookmarkManager without a dbus name is a temporary one, like those used by importers;
282 // no need to register them to dbus
283 if ( dbusPath != "/KBookmarkManager/" && dbusPath != "/KBookmarkManager/generated")
284 {
285 new KBookmarkManagerAdaptor(this);
286 QDBusConnection::sessionBus().registerObject( dbusPath, this );
287
288 QDBusConnection::sessionBus().connect(QString(), dbusPath, BOOKMARK_CHANGE_NOTIFY_INTERFACE,
289 "bookmarksChanged", this, SLOT(notifyChanged(QString,QDBusMessage)));
290 QDBusConnection::sessionBus().connect(QString(), dbusPath, BOOKMARK_CHANGE_NOTIFY_INTERFACE,
291 "bookmarkConfigChanged", this, SLOT(notifyConfigChanged()));
292 }
293}
294
295void KBookmarkManager::slotFileChanged(const QString& path)
296{
297 if (path == d->m_bookmarksFile)
298 {
299 kDebug(7043) << "file changed (KDirWatch) " << path ;
300 // Reparse
301 parse();
302 // Tell our GUI
303 // (emit where group is "" to directly mark the root menu as dirty)
304 emit changed( "", QString() );
305 }
306}
307
308KBookmarkManager::~KBookmarkManager()
309{
310 if (!s_pSelf.isDestroyed()) {
311 s_pSelf->removeAll(this);
312 }
313
314 delete d;
315}
316
317bool KBookmarkManager::autoErrorHandlingEnabled() const
318{
319 return d->m_dialogAllowed;
320}
321
322void KBookmarkManager::setAutoErrorHandlingEnabled( bool enable, QWidget *parent )
323{
324 d->m_dialogAllowed = enable;
325 d->m_dialogParent = parent;
326}
327
328void KBookmarkManager::setUpdate( bool update )
329{
330 d->m_update = update;
331}
332
333QDomDocument KBookmarkManager::internalDocument() const
334{
335 if(!d->m_docIsLoaded)
336 {
337 parse();
338 d->m_toolbarDoc.clear();
339 }
340 return d->m_doc;
341}
342
343
344void KBookmarkManager::parse() const
345{
346 d->m_docIsLoaded = true;
347 //kDebug(7043) << "KBookmarkManager::parse " << d->m_bookmarksFile;
348 QFile file( d->m_bookmarksFile );
349 if ( !file.open( QIODevice::ReadOnly ) )
350 {
351 kWarning() << "Can't open " << d->m_bookmarksFile;
352 return;
353 }
354 d->m_doc = QDomDocument("xbel");
355 d->m_doc.setContent( &file );
356
357 if ( d->m_doc.documentElement().isNull() )
358 {
359 kWarning() << "KBookmarkManager::parse : main tag is missing, creating default " << d->m_bookmarksFile;
360 QDomElement element = d->m_doc.createElement("xbel");
361 d->m_doc.appendChild(element);
362 }
363
364 QDomElement docElem = d->m_doc.documentElement();
365
366 QString mainTag = docElem.tagName();
367 if ( mainTag != "xbel" )
368 kWarning() << "KBookmarkManager::parse : unknown main tag " << mainTag;
369
370 if(d->m_dbusObjectName.isNull())
371 {
372 d->m_dbusObjectName = docElem.attribute("dbusName");
373 }
374 else if(docElem.attribute("dbusName") != d->m_dbusObjectName)
375 {
376 docElem.setAttribute("dbusName", d->m_dbusObjectName);
377 save();
378 }
379
380 QDomNode n = d->m_doc.documentElement().previousSibling();
381 if ( n.isProcessingInstruction() )
382 {
383 QDomProcessingInstruction pi = n.toProcessingInstruction();
384 pi.parentNode().removeChild(pi);
385 }
386
387 QDomProcessingInstruction pi;
388 pi = d->m_doc.createProcessingInstruction( "xml", PI_DATA );
389 d->m_doc.insertBefore( pi, docElem );
390
391 file.close();
392
393 d->m_map.setNeedsUpdate();
394}
395
396bool KBookmarkManager::save( bool toolbarCache ) const
397{
398 return saveAs( d->m_bookmarksFile, toolbarCache );
399}
400
401bool KBookmarkManager::saveAs( const QString & filename, bool toolbarCache ) const
402{
403 kDebug(7043) << "KBookmarkManager::save " << filename;
404
405 // Save the bookmark toolbar folder for quick loading
406 // but only when it will actually make things quicker
407 const QString cacheFilename = filename + QLatin1String(".tbcache");
408 if(toolbarCache && !root().isToolbarGroup())
409 {
410 KSaveFile cacheFile( cacheFilename );
411 if ( cacheFile.open() )
412 {
413 QString str;
414 QTextStream stream(&str, QIODevice::WriteOnly);
415 stream << root().findToolbar();
416 const QByteArray cstr = str.toUtf8();
417 cacheFile.write( cstr.data(), cstr.length() );
418 cacheFile.finalize();
419 }
420 }
421 else // remove any (now) stale cache
422 {
423 QFile::remove( cacheFilename );
424 }
425
426 // Create parent dirs
427 QFileInfo info(filename);
428 QDir().mkpath(info.absolutePath());
429
430 KSaveFile file( filename );
431 if ( file.open() )
432 {
433 file.simpleBackupFile( file.fileName(), QString(), ".bak" );
434 QTextStream stream(&file);
435 stream.setCodec( QTextCodec::codecForName( "UTF-8" ) );
436 stream << internalDocument().toString();
437 stream.flush();
438 if ( file.finalize() )
439 {
440 return true;
441 }
442 }
443
444 static int hadSaveError = false;
445 file.abort();
446 if ( !hadSaveError ) {
447 QString err = i18n("Unable to save bookmarks in %1. Reported error was: %2. "
448 "This error message will only be shown once. The cause "
449 "of the error needs to be fixed as quickly as possible, "
450 "which is most likely a full hard drive.",
451 filename, file.errorString());
452
453 if (d->m_dialogAllowed && qApp->type() != QApplication::Tty && QThread::currentThread() == qApp->thread())
454 KMessageBox::error( QApplication::activeWindow(), err );
455
456 kError() << QString("Unable to save bookmarks in %1. File reported the following error-code: %2.").arg(filename).arg(file.error());
457 emit const_cast<KBookmarkManager*>(this)->error(err);
458 }
459 hadSaveError = true;
460 return false;
461}
462
463QString KBookmarkManager::path() const
464{
465 return d->m_bookmarksFile;
466}
467
468KBookmarkGroup KBookmarkManager::root() const
469{
470 return KBookmarkGroup(internalDocument().documentElement());
471}
472
473KBookmarkGroup KBookmarkManager::toolbar()
474{
475 kDebug(7043) << "KBookmarkManager::toolbar begin";
476 // Only try to read from a toolbar cache if the full document isn't loaded
477 if(!d->m_docIsLoaded)
478 {
479 kDebug(7043) << "KBookmarkManager::toolbar trying cache";
480 const QString cacheFilename = d->m_bookmarksFile + QLatin1String(".tbcache");
481 QFileInfo bmInfo(d->m_bookmarksFile);
482 QFileInfo cacheInfo(cacheFilename);
483 if (d->m_toolbarDoc.isNull() &&
484 QFile::exists(cacheFilename) &&
485 bmInfo.lastModified() < cacheInfo.lastModified())
486 {
487 kDebug(7043) << "KBookmarkManager::toolbar reading file";
488 QFile file( cacheFilename );
489
490 if ( file.open( QIODevice::ReadOnly ) )
491 {
492 d->m_toolbarDoc = QDomDocument("cache");
493 d->m_toolbarDoc.setContent( &file );
494 kDebug(7043) << "KBookmarkManager::toolbar opened";
495 }
496 }
497 if (!d->m_toolbarDoc.isNull())
498 {
499 kDebug(7043) << "KBookmarkManager::toolbar returning element";
500 QDomElement elem = d->m_toolbarDoc.firstChild().toElement();
501 return KBookmarkGroup(elem);
502 }
503 }
504
505 // Fallback to the normal way if there is no cache or if the bookmark file
506 // is already loaded
507 QDomElement elem = root().findToolbar();
508 if (elem.isNull())
509 {
510 // Root is the bookmark toolbar if none has been set.
511 // Make it explicit to speed up invocations of findToolbar()
512 root().internalElement().setAttribute("toolbar", "yes");
513 return root();
514 }
515 else
516 return KBookmarkGroup(elem);
517}
518
519KBookmark KBookmarkManager::findByAddress( const QString & address )
520{
521 //kDebug(7043) << "KBookmarkManager::findByAddress " << address;
522 KBookmark result = root();
523 // The address is something like /5/10/2+
524 const QStringList addresses = address.split(QRegExp("[/+]"),QString::SkipEmptyParts);
525 // kWarning() << addresses.join(",");
526 for ( QStringList::const_iterator it = addresses.begin() ; it != addresses.end() ; )
527 {
528 bool append = ((*it) == "+");
529 uint number = (*it).toUInt();
530 Q_ASSERT(result.isGroup());
531 KBookmarkGroup group = result.toGroup();
532 KBookmark bk = group.first(), lbk = bk; // last non-null bookmark
533 for ( uint i = 0 ; ( (i<number) || append ) && !bk.isNull() ; ++i ) {
534 lbk = bk;
535 bk = group.next(bk);
536 //kWarning() << i;
537 }
538 it++;
539 //kWarning() << "found section";
540 result = bk;
541 }
542 if (result.isNull()) {
543 kWarning() << "KBookmarkManager::findByAddress: couldn't find item " << address;
544 }
545 //kWarning() << "found " << result.address();
546 return result;
547 }
548
549void KBookmarkManager::emitChanged()
550{
551 emitChanged(root());
552}
553
554
555void KBookmarkManager::emitChanged( const KBookmarkGroup & group )
556{
557 (void) save(); // KDE5 TODO: emitChanged should return a bool? Maybe rename it to saveAndEmitChanged?
558
559 // Tell the other processes too
560 // kDebug(7043) << "KBookmarkManager::emitChanged : broadcasting change " << group.address();
561
562 emit bookmarksChanged(group.address());
563
564 // We do get our own broadcast, so no need for this anymore
565 //emit changed( group );
566}
567
568void KBookmarkManager::emitConfigChanged()
569{
570 emit bookmarkConfigChanged();
571}
572
573void KBookmarkManager::notifyCompleteChange( const QString &caller ) // DBUS call
574{
575 if (!d->m_update)
576 return;
577
578 kDebug(7043) << "KBookmarkManager::notifyCompleteChange";
579 // The bk editor tells us we should reload everything
580 // Reparse
581 parse();
582 // Tell our GUI
583 // (emit where group is "" to directly mark the root menu as dirty)
584 emit changed( "", caller );
585}
586
587void KBookmarkManager::notifyConfigChanged() // DBUS call
588{
589 kDebug() << "reloaded bookmark config!";
590 KBookmarkSettings::self()->readSettings();
591 parse(); // reload, and thusly recreate the menus
592 emit configChanged();
593}
594
595void KBookmarkManager::notifyChanged( const QString &groupAddress, const QDBusMessage &msg ) // DBUS call
596{
597 kDebug() << "KBookmarkManager::notifyChanged ( "<<groupAddress<<")";
598 if (!d->m_update)
599 return;
600
601 // Reparse (the whole file, no other choice)
602 // if someone else notified us
603 if (msg.service() != QDBusConnection::sessionBus().baseService())
604 parse();
605
606 //kDebug(7043) << "KBookmarkManager::notifyChanged " << groupAddress;
607 //KBookmarkGroup group = findByAddress( groupAddress ).toGroup();
608 //Q_ASSERT(!group.isNull());
609 emit changed( groupAddress, QString() );
610}
611
612void KBookmarkManager::setEditorOptions( const QString& caption, bool browser )
613{
614 d->m_editorCaption = caption;
615 d->m_browserEditor = browser;
616}
617
618void KBookmarkManager::slotEditBookmarks()
619{
620 QStringList args;
621 if ( !d->m_editorCaption.isEmpty() )
622 args << QLatin1String("--customcaption") << d->m_editorCaption;
623 if ( !d->m_browserEditor )
624 args << QLatin1String("--nobrowser");
625 if( !d->m_dbusObjectName.isEmpty() )
626 args << QLatin1String("--dbusObjectName") << d->m_dbusObjectName;
627 args << d->m_bookmarksFile;
628 QProcess::startDetached("keditbookmarks", args);
629}
630
631void KBookmarkManager::slotEditBookmarksAtAddress( const QString& address )
632{
633 QStringList args;
634 if ( !d->m_editorCaption.isEmpty() )
635 args << QLatin1String("--customcaption") << d->m_editorCaption;
636 if ( !d->m_browserEditor )
637 args << QLatin1String("--nobrowser");
638 if( !d->m_dbusObjectName.isEmpty() )
639 args << QLatin1String("--dbusObjectName") << d->m_dbusObjectName;
640 args << QLatin1String("--address") << address
641 << d->m_bookmarksFile;
642 QProcess::startDetached("keditbookmarks", args);
643}
644
646bool KBookmarkManager::updateAccessMetadata( const QString & url )
647{
648 d->m_map.update(this);
649 QList<KBookmark> list = d->m_map.find(url);
650 if ( list.count() == 0 )
651 return false;
652
653 for ( QList<KBookmark>::iterator it = list.begin();
654 it != list.end(); ++it )
655 (*it).updateAccessMetadata();
656
657 return true;
658}
659
660void KBookmarkManager::updateFavicon( const QString &url, const QString &/*faviconurl*/ )
661{
662 d->m_map.update(this);
663 QList<KBookmark> list = d->m_map.find(url);
664 for ( QList<KBookmark>::iterator it = list.begin();
665 it != list.end(); ++it )
666 {
667 // TODO - update favicon data based on faviconurl
668 // but only when the previously used icon
669 // isn't a manually set one.
670 }
671}
672
673KBookmarkManager* KBookmarkManager::userBookmarksManager()
674{
675 const QString bookmarksFile = KStandardDirs::locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));
676 KBookmarkManager* bookmarkManager = KBookmarkManager::managerForFile( bookmarksFile, "konqueror" );
677 bookmarkManager->setEditorOptions(KGlobal::caption(), true);
678 return bookmarkManager;
679}
680
681KBookmarkSettings* KBookmarkSettings::s_self = 0;
682
683void KBookmarkSettings::readSettings()
684{
685 KConfig config("kbookmarkrc", KConfig::NoGlobals);
686 KConfigGroup cg(&config, "Bookmarks");
687
688 // add bookmark dialog usage - no reparse
689 s_self->m_advancedaddbookmark = cg.readEntry("AdvancedAddBookmarkDialog", false);
690
691 // this one alters the menu, therefore it needs a reparse
692 s_self->m_contextmenu = cg.readEntry("ContextMenuActions", true);
693}
694
695KBookmarkSettings *KBookmarkSettings::self()
696{
697 if (!s_self)
698 {
699 s_self = new KBookmarkSettings;
700 readSettings();
701 }
702 return s_self;
703}
704
706
707bool KBookmarkOwner::enableOption(BookmarkOption action) const
708{
709 if(action == ShowAddBookmark)
710 return true;
711 if(action == ShowEditBookmark)
712 return true;
713 return false;
714}
715
716KBookmarkDialog * KBookmarkOwner::bookmarkDialog(KBookmarkManager * mgr, QWidget * parent)
717{
718 return new KBookmarkDialog(mgr, parent);
719}
720
721void KBookmarkOwner::openFolderinTabs(const KBookmarkGroup &)
722{
723
724}
725
726#include "kbookmarkmanager.moc"
KBookmarkDialog
This class provides a Dialog for editing properties, adding Bookmarks and creating new folders.
Definition: kbookmarkdialog.h:45
KBookmarkGroupTraverser
Definition: kbookmark.h:459
KBookmarkGroup
A group of bookmarks.
Definition: kbookmark.h:348
KBookmarkGroup::findToolbar
QDomElement findToolbar() const
Definition: kbookmark.cc:247
KBookmarkManagerAdaptor
Definition: kbookmarkmanageradaptor_p.h:28
KBookmarkManager
This class implements the reading/writing of bookmarks in XML.
Definition: kbookmarkmanager.h:66
KBookmarkManager::configChanged
void configChanged()
Signals that the config changed.
KBookmarkManager::autoErrorHandlingEnabled
bool autoErrorHandlingEnabled() const
Check whether auto error handling is enabled.
Definition: kbookmarkmanager.cc:317
KBookmarkManager::setAutoErrorHandlingEnabled
void setAutoErrorHandlingEnabled(bool enable, QWidget *parent)
Enable or disable auto error handling is enabled.
Definition: kbookmarkmanager.cc:322
KBookmarkManager::findByAddress
KBookmark findByAddress(const QString &address)
Definition: kbookmarkmanager.cc:519
KBookmarkManager::notifyChanged
void notifyChanged(const QString &groupAddress, const QDBusMessage &msg)
Emit the changed signal for the group whose address is given.
Definition: kbookmarkmanager.cc:595
KBookmarkManager::managerForFile
static KBookmarkManager * managerForFile(const QString &bookmarksFile, const QString &dbusObjectName)
This static function will return an instance of the KBookmarkManager, responsible for the given bookm...
Definition: kbookmarkmanager.cc:150
KBookmarkManager::updateFavicon
void updateFavicon(const QString &url, const QString &faviconurl)
Definition: kbookmarkmanager.cc:660
KBookmarkManager::internalDocument
QDomDocument internalDocument() const
Definition: kbookmarkmanager.cc:333
KBookmarkManager::updateAccessMetadata
bool updateAccessMetadata(const QString &url)
Update access time stamps for a given url.
Definition: kbookmarkmanager.cc:646
KBookmarkManager::toolbar
KBookmarkGroup toolbar()
This returns the root of the toolbar menu.
Definition: kbookmarkmanager.cc:473
KBookmarkManager::notifyConfigChanged
void notifyConfigChanged()
Definition: kbookmarkmanager.cc:587
KBookmarkManager::slotEditBookmarks
void slotEditBookmarks()
Definition: kbookmarkmanager.cc:618
KBookmarkManager::setUpdate
void setUpdate(bool update)
Set the update flag.
Definition: kbookmarkmanager.cc:328
KBookmarkManager::bookmarkConfigChanged
void bookmarkConfigChanged()
Signal send over DBUS.
KBookmarkManager::userBookmarksManager
static KBookmarkManager * userBookmarksManager()
Returns a pointer to the user's main (konqueror) bookmark collection.
Definition: kbookmarkmanager.cc:673
KBookmarkManager::save
bool save(bool toolbarCache=true) const
Save the bookmarks to an XML file on disk.
Definition: kbookmarkmanager.cc:396
KBookmarkManager::path
QString path() const
This will return the path that this manager is using to read the bookmarks.
Definition: kbookmarkmanager.cc:463
KBookmarkManager::notifyCompleteChange
void notifyCompleteChange(const QString &caller)
Reparse the whole bookmarks file and notify about the change Doesn't send signal over DBUS to the oth...
Definition: kbookmarkmanager.cc:573
KBookmarkManager::root
KBookmarkGroup root() const
This will return the root bookmark.
Definition: kbookmarkmanager.cc:468
KBookmarkManager::managerForExternalFile
static KBookmarkManager * managerForExternalFile(const QString &bookmarksFile)
Returns a KBookmarkManager, which will use KDirWatch for change detection This is important when shar...
Definition: kbookmarkmanager.cc:172
KBookmarkManager::error
void error(const QString &errorMessage)
Emitted when an error occurs.
KBookmarkManager::saveAs
bool saveAs(const QString &filename, bool toolbarCache=true) const
Save the bookmarks to the given XML file on disk.
Definition: kbookmarkmanager.cc:401
KBookmarkManager::bookmarksChanged
void bookmarksChanged(QString groupAddress)
Signal send over DBUS.
KBookmarkManager::emitConfigChanged
void emitConfigChanged()
Definition: kbookmarkmanager.cc:568
KBookmarkManager::slotEditBookmarksAtAddress
void slotEditBookmarksAtAddress(const QString &address)
Definition: kbookmarkmanager.cc:631
KBookmarkManager::~KBookmarkManager
~KBookmarkManager()
Destructor.
Definition: kbookmarkmanager.cc:308
KBookmarkManager::createTempManager
static KBookmarkManager * createTempManager()
only used for KBookmarkBar
Definition: kbookmarkmanager.cc:196
KBookmarkManager::setEditorOptions
void setEditorOptions(const QString &caption, bool browser)
Set options with which slotEditBookmarks called keditbookmarks this can be used to change the appeara...
Definition: kbookmarkmanager.cc:612
KBookmarkManager::emitChanged
void emitChanged()
Saves the bookmark file and notifies everyone.
Definition: kbookmarkmanager.cc:549
KBookmarkManager::changed
void changed(const QString &groupAddress, const QString &caller)
Signals that the group (or any of its children) with the address groupAddress (e.g.
KBookmarkOwner::enableOption
virtual bool enableOption(BookmarkOption option) const
Returns true if action should be shown in the menu The default is to show both a add and editBookmark...
Definition: kbookmarkmanager.cc:707
KBookmarkOwner::bookmarkDialog
virtual KBookmarkDialog * bookmarkDialog(KBookmarkManager *mgr, QWidget *parent)
Definition: kbookmarkmanager.cc:716
KBookmarkOwner::BookmarkOption
BookmarkOption
Definition: kbookmarkmanager.h:422
KBookmarkOwner::ShowAddBookmark
@ ShowAddBookmark
Definition: kbookmarkmanager.h:422
KBookmarkOwner::ShowEditBookmark
@ ShowEditBookmark
Definition: kbookmarkmanager.h:422
KBookmarkOwner::openFolderinTabs
virtual void openFolderinTabs(const KBookmarkGroup &bm)
Called if the user wants to open every bookmark in this folder in a new tab.
Definition: kbookmarkmanager.cc:721
KBookmarkSettings
Definition: kbookmarkmenu_p.h:85
KBookmarkSettings::m_advancedaddbookmark
bool m_advancedaddbookmark
Definition: kbookmarkmenu_p.h:87
KBookmarkSettings::m_contextmenu
bool m_contextmenu
Definition: kbookmarkmenu_p.h:88
KBookmarkSettings::s_self
static KBookmarkSettings * s_self
Definition: kbookmarkmenu_p.h:89
KBookmarkSettings::readSettings
static void readSettings()
Definition: kbookmarkmanager.cc:683
KBookmarkSettings::self
static KBookmarkSettings * self()
Definition: kbookmarkmanager.cc:695
KBookmark
Definition: kbookmark.h:35
KBookmark::isNull
bool isNull() const
Definition: kbookmark.cc:295
KBookmark::isGroup
bool isGroup() const
Whether the bookmark is a group or a normal bookmark.
Definition: kbookmark.cc:283
KBookmark::toGroup
KBookmarkGroup toGroup() const
Convert this to a group - do this only if isGroup() returns true.
Definition: kbookmark.cc:465
KBookmark::isSeparator
bool isSeparator() const
Whether the bookmark is a separator.
Definition: kbookmark.cc:290
KBookmark::internalElement
QDomElement internalElement() const
Definition: kbookmark.cc:496
KConfigGroup
KConfigGroup::readEntry
QString readEntry(const char *key, const char *aDefault=0) const
KConfig
KConfig::NoGlobals
NoGlobals
KDirWatch
KDirWatch::addFile
void addFile(const QString &file)
KMessageBox::error
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
KSaveFile
KSaveFile::finalize
bool finalize()
KSaveFile::fileName
QString fileName() const
KSaveFile::open
virtual bool open(OpenMode flags=QIODevice::ReadWrite)
KSaveFile::error
QFile::FileError error() const
KSaveFile::errorString
QString errorString() const
KSaveFile::abort
void abort()
KSaveFile::simpleBackupFile
static bool simpleBackupFile(const QString &filename, const QString &backupDir=QString(), const QString &backupExtension=QLatin1String("~"))
KStandardDirs::locateLocal
static QString locateLocal(const char *type, const QString &filename, bool createDir, const KComponentData &cData=KGlobal::mainComponent())
QList
QMap
QWidget
K_GLOBAL_STATIC
#define K_GLOBAL_STATIC(TYPE, NAME)
kDebug
#define kDebug
kWarning
#define kWarning
kbookmarkdialog.h
kbookmarkimporter.h
BOOKMARK_CHANGE_NOTIFY_INTERFACE
#define BOOKMARK_CHANGE_NOTIFY_INTERFACE
Definition: kbookmarkmanager.cc:47
PI_DATA
#define PI_DATA
Definition: kbookmarkmanager.cc:203
createXbelTopLevelElement
static QDomElement createXbelTopLevelElement(QDomDocument &doc)
Definition: kbookmarkmanager.cc:205
lookupExisting
static KBookmarkManager * lookupExisting(const QString &bookmarksFile)
Definition: kbookmarkmanager.cc:139
kbookmarkmanager.h
kbookmarkmanageradaptor_p.h
kbookmarkmenu.h
kbookmarkmenu_p.h
kconfiggroup.h
kdebug.h
kdirwatch.h
klocale.h
i18n
QString i18n(const char *text)
kmessagebox.h
ksavefile.h
kstandarddirs.h
caption
QString caption()
config
KSharedConfigPtr config()
group
group
find
KAction * find(const QObject *recvr, const char *slot, QObject *parent)
begin
const KShortcut & begin()
end
const KShortcut & end()
parse
QList< Action > parse(QSettings &ini)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal