00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kbookmarkmenu.h"
00022 #include "kbookmarkmenu_p.h"
00023
00024 #include "kbookmarkdialog.h"
00025
00026 #include <kauthorized.h>
00027 #include <kdebug.h>
00028 #include <kiconloader.h>
00029 #include <klocale.h>
00030 #include <kmessagebox.h>
00031 #include <kmenu.h>
00032 #include <kstandardshortcut.h>
00033 #include <kstandardaction.h>
00034 #include <kstringhandler.h>
00035 #include <krun.h>
00036 #include <kactioncollection.h>
00037
00038 #include <qclipboard.h>
00039 #include <qmimedata.h>
00040
00041
00042 #include <QtCore/QStack>
00043 #include <QtGui/QHeaderView>
00044 #include <QtGui/QApplication>
00045
00046
00047
00048
00049 class KBookmarkMenuPrivate
00050 {
00051 public:
00052 KBookmarkMenuPrivate()
00053 : newBookmarkFolder(0),
00054 addAddBookmark(0),
00055 bookmarksToFolder(0)
00056 {
00057 }
00058
00059 KAction *newBookmarkFolder;
00060 KAction *addAddBookmark;
00061 KAction *bookmarksToFolder;
00062 };
00063
00064
00065 KBookmarkMenu::KBookmarkMenu( KBookmarkManager* mgr,
00066 KBookmarkOwner * _owner, KMenu * _parentMenu,
00067 KActionCollection * actionCollection)
00068 : QObject(),
00069 m_actionCollection( actionCollection ),
00070 d (new KBookmarkMenuPrivate()),
00071 m_bIsRoot(true),
00072 m_pManager(mgr), m_pOwner(_owner),
00073 m_parentMenu( _parentMenu ),
00074 m_parentAddress( QString("") )
00075 {
00076 m_parentMenu->setKeyboardShortcutsEnabled( true );
00077
00078
00079
00080 connect( _parentMenu, SIGNAL( aboutToShow() ),
00081 SLOT( slotAboutToShow() ) );
00082
00083 if ( KBookmarkSettings::self()->m_contextmenu )
00084 {
00085 m_parentMenu->setContextMenuPolicy(Qt::CustomContextMenu);
00086 connect(m_parentMenu, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotCustomContextMenu(const QPoint &)));
00087 }
00088
00089 connect( m_pManager, SIGNAL( changed(const QString &, const QString &) ),
00090 SLOT( slotBookmarksChanged(const QString &) ) );
00091
00092 m_bDirty = true;
00093 addActions();
00094 }
00095
00096 void KBookmarkMenu::addActions()
00097 {
00098 if ( m_bIsRoot )
00099 {
00100 addAddBookmark();
00101 addAddBookmarksList();
00102 addNewFolder();
00103 addEditBookmarks();
00104 }
00105 else
00106 {
00107 if ( m_parentMenu->actions().count() > 0 )
00108 m_parentMenu->addSeparator();
00109
00110 addOpenInTabs();
00111 addAddBookmark();
00112 addAddBookmarksList();
00113 addNewFolder();
00114 }
00115 }
00116
00117 KBookmarkMenu::KBookmarkMenu( KBookmarkManager* mgr,
00118 KBookmarkOwner * _owner, KMenu * _parentMenu,
00119 const QString & parentAddress)
00120 : QObject(),
00121 m_actionCollection( new KActionCollection(this) ),
00122 d (new KBookmarkMenuPrivate()),
00123 m_bIsRoot(false),
00124 m_pManager(mgr), m_pOwner(_owner),
00125 m_parentMenu( _parentMenu ),
00126 m_parentAddress( parentAddress )
00127 {
00128 m_parentMenu->setKeyboardShortcutsEnabled( true );
00129 connect( _parentMenu, SIGNAL( aboutToShow() ), SLOT( slotAboutToShow() ) );
00130 if ( KBookmarkSettings::self()->m_contextmenu )
00131 {
00132 m_parentMenu->setContextMenuPolicy(Qt::CustomContextMenu);
00133 connect(m_parentMenu, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotCustomContextMenu(const QPoint &)));
00134 }
00135 m_bDirty = true;
00136 }
00137
00138 KBookmarkMenu::~KBookmarkMenu()
00139 {
00140 qDeleteAll( m_lstSubMenus );
00141 qDeleteAll( m_actions );
00142 delete d;
00143 }
00144
00145 void KBookmarkMenu::ensureUpToDate()
00146 {
00147 slotAboutToShow();
00148 }
00149
00150 void KBookmarkMenu::slotAboutToShow()
00151 {
00152
00153 if ( m_bDirty )
00154 {
00155 m_bDirty = false;
00156 clear();
00157 refill();
00158 m_parentMenu->adjustSize();
00159 }
00160 }
00161
00162 void KBookmarkMenu::slotCustomContextMenu( const QPoint & pos)
00163 {
00164 QAction * action = m_parentMenu->actionAt(pos);
00165 KMenu * menu = contextMenu(action);
00166 if(!menu)
00167 return;
00168 menu->setAttribute(Qt::WA_DeleteOnClose);
00169 menu->popup(m_parentMenu->mapToGlobal(pos));
00170 }
00171
00172 KMenu * KBookmarkMenu::contextMenu( QAction * action )
00173 {
00174 KBookmarkActionInterface* act = dynamic_cast<KBookmarkActionInterface *>(action);
00175 if (!act)
00176 return 0;
00177 return new KBookmarkContextMenu(act->bookmark(), m_pManager, m_pOwner);
00178 }
00179
00180 bool KBookmarkMenu::isRoot() const
00181 {
00182 return m_bIsRoot;
00183 }
00184
00185 bool KBookmarkMenu::isDirty() const
00186 {
00187 return m_bDirty;
00188 }
00189
00190 QString KBookmarkMenu::parentAddress() const
00191 {
00192 return m_parentAddress;
00193 }
00194
00195 KBookmarkManager * KBookmarkMenu::manager() const
00196 {
00197 return m_pManager;
00198 }
00199
00200 KBookmarkOwner * KBookmarkMenu::owner() const
00201 {
00202 return m_pOwner;
00203 }
00204
00205 KMenu * KBookmarkMenu::parentMenu() const
00206 {
00207 return m_parentMenu;
00208 }
00209
00210
00211
00212
00213
00214 KBookmarkActionInterface::KBookmarkActionInterface(const KBookmark &bk)
00215 : bm(bk)
00216 {}
00217
00218 KBookmarkActionInterface::~KBookmarkActionInterface()
00219 {
00220 }
00221
00222 const KBookmark KBookmarkActionInterface::bookmark() const
00223 {
00224 return bm;
00225 }
00226
00227
00228
00229
00230
00231
00232 KBookmarkContextMenu::KBookmarkContextMenu(const KBookmark & bk, KBookmarkManager * manager, KBookmarkOwner *owner, QWidget * parent)
00233 : KMenu(parent), bm(bk), m_pManager(manager), m_pOwner(owner)
00234 {
00235 connect(this, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()));
00236 }
00237
00238 void KBookmarkContextMenu::slotAboutToShow()
00239 {
00240 addActions();
00241 }
00242
00243 void KBookmarkContextMenu::addActions()
00244 {
00245 if (bm.isGroup())
00246 {
00247 addOpenFolderInTabs();
00248 addBookmark();
00249 addFolderActions();
00250 }
00251 else
00252 {
00253 addBookmark();
00254 addBookmarkActions();
00255 }
00256 }
00257
00258 KBookmarkContextMenu::~KBookmarkContextMenu()
00259 {
00260
00261 }
00262
00263
00264 void KBookmarkContextMenu::addBookmark()
00265 {
00266 if( m_pOwner && m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) )
00267 addAction( KIcon("bookmark-new"), i18n( "Add Bookmark Here" ), this, SLOT(slotInsert()) );
00268 }
00269
00270 void KBookmarkContextMenu::addFolderActions()
00271 {
00272 addAction( i18n( "Open Folder in Bookmark Editor" ), this, SLOT(slotEditAt()) );
00273 addProperties();
00274 addSeparator();
00275 addAction( KIcon("edit-delete"), i18n( "Delete Folder" ), this, SLOT(slotRemove()) );
00276 }
00277
00278
00279 void KBookmarkContextMenu::addProperties()
00280 {
00281 addAction( i18n( "Properties" ), this, SLOT(slotProperties()) );
00282 }
00283
00284 void KBookmarkContextMenu::addBookmarkActions()
00285 {
00286 addAction( i18n( "Copy Link Address" ), this, SLOT(slotCopyLocation()) );
00287 addProperties();
00288 addSeparator();
00289 addAction( KIcon("edit-delete"), i18n( "Delete Bookmark" ), this, SLOT(slotRemove()) );
00290 }
00291
00292 void KBookmarkContextMenu::addOpenFolderInTabs()
00293 {
00294 if(m_pOwner->supportsTabs())
00295 addAction(KIcon("tab-new"), i18n( "Open Folder in Tabs" ), this, SLOT( slotOpenFolderInTabs() ) );
00296 }
00297
00298 void KBookmarkContextMenu::slotEditAt()
00299 {
00300
00301 m_pManager->slotEditBookmarksAtAddress( bm.address() );
00302 }
00303
00304 void KBookmarkContextMenu::slotProperties()
00305 {
00306
00307
00308 KBookmarkDialog * dlg = m_pOwner->bookmarkDialog(m_pManager, QApplication::activeWindow());
00309 dlg->editBookmark(bm);
00310 delete dlg;
00311 }
00312
00313 void KBookmarkContextMenu::slotInsert()
00314 {
00315
00316
00317 QString url = m_pOwner->currentUrl();
00318 if (url.isEmpty())
00319 {
00320 KMessageBox::error( QApplication::activeWindow(), i18n("Cannot add bookmark with empty URL."));
00321 return;
00322 }
00323 QString title = m_pOwner->currentTitle();
00324 if (title.isEmpty())
00325 title = url;
00326
00327 if (bm.isGroup())
00328 {
00329 KBookmarkGroup parentBookmark = bm.toGroup();
00330 Q_ASSERT(!parentBookmark.isNull());
00331 parentBookmark.addBookmark( title, KUrl(url) );
00332 m_pManager->emitChanged( parentBookmark );
00333 }
00334 else
00335 {
00336 KBookmarkGroup parentBookmark = bm.parentGroup();
00337 Q_ASSERT(!parentBookmark.isNull());
00338 KBookmark newBookmark = parentBookmark.addBookmark( title, KUrl(m_pOwner->currentUrl()) );
00339 parentBookmark.moveBookmark( newBookmark, parentBookmark.previous(bm) );
00340 m_pManager->emitChanged( parentBookmark );
00341 }
00342 }
00343
00344 void KBookmarkContextMenu::slotRemove()
00345 {
00346
00347
00348 bool folder = bm.isGroup();
00349
00350 if (KMessageBox::warningContinueCancel(
00351 QApplication::activeWindow(),
00352 folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text())
00353 : i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()),
00354 folder ? i18n("Bookmark Folder Deletion")
00355 : i18n("Bookmark Deletion"),
00356 KStandardGuiItem::del())
00357 != KMessageBox::Continue
00358 )
00359 return;
00360
00361 KBookmarkGroup parentBookmark = bm.parentGroup();
00362 parentBookmark.deleteBookmark( bm );
00363 m_pManager->emitChanged( parentBookmark );
00364 }
00365
00366 void KBookmarkContextMenu::slotCopyLocation()
00367 {
00368
00369
00370 if ( !bm.isGroup() )
00371 {
00372 QMimeData* mimeData = new QMimeData;
00373 bm.populateMimeData( mimeData );
00374 QApplication::clipboard()->setMimeData( mimeData, QClipboard::Selection );
00375 mimeData = new QMimeData;
00376 bm.populateMimeData( mimeData );
00377 QApplication::clipboard()->setMimeData( mimeData, QClipboard::Clipboard );
00378 }
00379 }
00380
00381 void KBookmarkContextMenu::slotOpenFolderInTabs()
00382 {
00383 owner()->openFolderinTabs(bookmark().toGroup());
00384 }
00385
00386 KBookmarkManager * KBookmarkContextMenu::manager() const
00387 {
00388 return m_pManager;
00389 }
00390
00391 KBookmarkOwner * KBookmarkContextMenu::owner() const
00392 {
00393 return m_pOwner;
00394 }
00395
00396 KBookmark KBookmarkContextMenu::bookmark() const
00397 {
00398 return bm;
00399 }
00400
00401
00402
00403
00404
00405 void KBookmarkMenu::slotBookmarksChanged( const QString & groupAddress )
00406 {
00407 kDebug(7043)<<"KBookmarkMenu::slotBookmarksChanged( "<<groupAddress;
00408 if ( groupAddress == m_parentAddress )
00409 {
00410
00411 m_bDirty = true;
00412 }
00413 else
00414 {
00415
00416 for ( QList<KBookmarkMenu *>::iterator it = m_lstSubMenus.begin(), end = m_lstSubMenus.end() ;
00417 it != end ; ++it ) {
00418 (*it)->slotBookmarksChanged( groupAddress );
00419 }
00420 }
00421 }
00422
00423 void KBookmarkMenu::clear()
00424 {
00425 qDeleteAll( m_lstSubMenus );
00426 m_lstSubMenus.clear();
00427
00428 for ( QList<QAction *>::iterator it = m_actions.begin(), end = m_actions.end() ;
00429 it != end ; ++it )
00430 {
00431 m_parentMenu->removeAction(*it);
00432 delete *it;
00433 }
00434
00435 m_parentMenu->clear();
00436 m_actions.clear();
00437 }
00438
00439 void KBookmarkMenu::refill()
00440 {
00441
00442 if(m_bIsRoot)
00443 addActions();
00444 fillBookmarks();
00445 if(!m_bIsRoot)
00446 addActions();
00447 }
00448
00449 void KBookmarkMenu::addOpenInTabs()
00450 {
00451 if( !m_pOwner || !m_pOwner->supportsTabs() || !KAuthorized::authorizeKAction("bookmarks") )
00452 return;
00453
00454 QString title = i18n( "Open Folder in Tabs" );
00455
00456 KAction * paOpenFolderInTabs = new KAction( title, this );
00457 paOpenFolderInTabs->setIcon( KIcon("tab-new") );
00458 paOpenFolderInTabs->setHelpText( i18n( "Open all bookmarks in this folder as a new tab." ) );
00459 connect( paOpenFolderInTabs, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenFolderInTabs() ) );
00460
00461 m_parentMenu->addAction(paOpenFolderInTabs);
00462 m_actions.append( paOpenFolderInTabs );
00463 }
00464
00465 void KBookmarkMenu::addAddBookmarksList()
00466 {
00467 if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) || !m_pOwner->supportsTabs() || !KAuthorized::authorizeKAction("bookmarks") )
00468 return;
00469
00470 if (d->bookmarksToFolder == 0) {
00471 QString title = i18n( "Bookmark Tabs as Folder..." );
00472 d->bookmarksToFolder = new KAction( title, this );
00473 m_actionCollection->addAction( m_bIsRoot ? "add_bookmarks_list" : 0, d->bookmarksToFolder);
00474 d->bookmarksToFolder->setIcon( KIcon( "bookmark-new-list" ) );
00475 d->bookmarksToFolder->setHelpText( i18n( "Add a folder of bookmarks for all open tabs." ) );
00476 connect( d->bookmarksToFolder, SIGNAL( triggered( bool ) ), this, SLOT( slotAddBookmarksList() ) );
00477 }
00478
00479 m_parentMenu->addAction(d->bookmarksToFolder);
00480 }
00481
00482 void KBookmarkMenu::addAddBookmark()
00483 {
00484 if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) || !KAuthorized::authorizeKAction("bookmarks") )
00485 return;
00486
00487 if (d->addAddBookmark == 0) {
00488 d->addAddBookmark = m_actionCollection->addAction(
00489 KStandardAction::AddBookmark,
00490 m_bIsRoot ? "add_bookmark" : 0,
00491 this,
00492 SLOT(slotAddBookmark()));
00493 if (!m_bIsRoot)
00494 d->addAddBookmark->setShortcut( QKeySequence() );
00495 }
00496
00497 m_parentMenu->addAction(d->addAddBookmark);
00498 }
00499
00500 void KBookmarkMenu::addEditBookmarks()
00501 {
00502 if( ( m_pOwner && !m_pOwner->enableOption(KBookmarkOwner::ShowEditBookmark) ) || !KAuthorized::authorizeKAction("bookmarks") )
00503 return;
00504
00505 KAction * m_paEditBookmarks = m_actionCollection->addAction(KStandardAction::EditBookmarks, "edit_bookmarks",
00506 m_pManager, SLOT(slotEditBookmarks()));
00507 m_parentMenu->addAction(m_paEditBookmarks);
00508 m_paEditBookmarks->setHelpText( i18n( "Edit your bookmark collection in a separate window" ) );
00509 }
00510
00511 void KBookmarkMenu::addNewFolder()
00512 {
00513 if( !m_pOwner || !m_pOwner->enableOption(KBookmarkOwner::ShowAddBookmark) || !KAuthorized::authorizeKAction("bookmarks"))
00514 return;
00515
00516 if (d->newBookmarkFolder == 0) {
00517 d->newBookmarkFolder = new KAction( i18n( "New Bookmark Folder..." ), this );
00518 d->newBookmarkFolder->setIcon( KIcon( "folder-new" ) );
00519 d->newBookmarkFolder->setHelpText( i18n( "Create a new bookmark folder in this menu" ) );
00520 connect( d->newBookmarkFolder, SIGNAL( triggered( bool ) ), this, SLOT( slotNewFolder() ) );
00521 }
00522
00523 m_parentMenu->addAction(d->newBookmarkFolder);
00524
00525 }
00526
00527 void KBookmarkMenu::fillBookmarks()
00528 {
00529 KBookmarkGroup parentBookmark = m_pManager->findByAddress( m_parentAddress ).toGroup();
00530 Q_ASSERT(!parentBookmark.isNull());
00531
00532 if ( m_bIsRoot && !parentBookmark.first().isNull() )
00533 {
00534 m_parentMenu->addSeparator();
00535 }
00536
00537 for ( KBookmark bm = parentBookmark.first(); !bm.isNull(); bm = parentBookmark.next(bm) )
00538 {
00539 m_parentMenu->addAction(actionForBookmark(bm));
00540 }
00541 }
00542
00543 QAction* KBookmarkMenu::actionForBookmark(const KBookmark &bm)
00544 {
00545 if ( bm.isGroup() )
00546 {
00547
00548 KActionMenu * actionMenu = new KBookmarkActionMenu( bm, this );
00549 m_actions.append( actionMenu );
00550 KBookmarkMenu *subMenu = new KBookmarkMenu( m_pManager, m_pOwner, actionMenu->menu(), bm.address() );
00551 m_lstSubMenus.append( subMenu );
00552 return actionMenu;
00553 }
00554 else if ( bm.isSeparator() )
00555 {
00556 QAction *sa = new QAction(this);
00557 sa->setSeparator(true);
00558 m_actions.append(sa);
00559 return sa;
00560 }
00561 else
00562 {
00563
00564 KAction * action = new KBookmarkAction( bm, m_pOwner, this );
00565 m_actions.append( action );
00566 return action;
00567 }
00568 }
00569
00570 void KBookmarkMenu::slotAddBookmarksList()
00571 {
00572 if( !m_pOwner || !m_pOwner->supportsTabs())
00573 return;
00574
00575 KBookmarkGroup parentBookmark = m_pManager->findByAddress( m_parentAddress ).toGroup();
00576
00577 KBookmarkDialog * dlg = m_pOwner->bookmarkDialog(m_pManager, QApplication::activeWindow());
00578 dlg->addBookmarks(m_pOwner->currentBookmarkList(), "", parentBookmark);
00579 delete dlg;
00580 }
00581
00582
00583 void KBookmarkMenu::slotAddBookmark()
00584 {
00585 if( !m_pOwner ) return;
00586 KBookmarkGroup parentBookmark = m_pManager->findByAddress( m_parentAddress ).toGroup();
00587
00588 if(KBookmarkSettings::self()->m_advancedaddbookmark)
00589 {
00590 KBookmarkDialog * dlg = m_pOwner->bookmarkDialog(m_pManager, QApplication::activeWindow() );
00591 dlg->addBookmark(m_pOwner->currentTitle(), KUrl(m_pOwner->currentUrl()), parentBookmark );
00592 delete dlg;
00593 }
00594 else
00595 {
00596 parentBookmark.addBookmark(m_pOwner->currentTitle(), KUrl(m_pOwner->currentUrl()));
00597 m_pManager->emitChanged( parentBookmark );
00598 }
00599
00600 }
00601
00602 void KBookmarkMenu::slotOpenFolderInTabs()
00603 {
00604 m_pOwner->openFolderinTabs(m_pManager->findByAddress( m_parentAddress ).toGroup());
00605 }
00606
00607 void KBookmarkMenu::slotNewFolder()
00608 {
00609 if ( !m_pOwner ) return;
00610 KBookmarkGroup parentBookmark = m_pManager->findByAddress( m_parentAddress ).toGroup();
00611 Q_ASSERT(!parentBookmark.isNull());
00612 KBookmarkDialog * dlg = m_pOwner->bookmarkDialog(m_pManager, QApplication::activeWindow());
00613 dlg->createNewFolder("", parentBookmark);
00614 delete dlg;
00615 }
00616
00617 void KImportedBookmarkMenu::slotNSLoad()
00618 {
00619 kDebug(7043)<<"**** slotNSLoad ****"<<m_type<<" "<<m_location;
00620
00621 parentMenu()->disconnect(SIGNAL(aboutToShow()));
00622
00623
00624 KBookmarkMenuImporter importer( manager(), this );
00625 importer.openBookmarks(m_location, m_type);
00626 }
00627
00628 KImportedBookmarkMenu::KImportedBookmarkMenu( KBookmarkManager* mgr,
00629 KBookmarkOwner * owner, KMenu * parentMenu,
00630 const QString & type, const QString & location )
00631 :KBookmarkMenu(mgr, owner, parentMenu, QString()), m_type(type), m_location(location)
00632 {
00633 connect(parentMenu, SIGNAL(aboutToShow()), this, SLOT(slotNSLoad()));
00634 }
00635
00636 KImportedBookmarkMenu::KImportedBookmarkMenu( KBookmarkManager* mgr,
00637 KBookmarkOwner * owner, KMenu * parentMenu)
00638 :KBookmarkMenu(mgr, owner, parentMenu, QString()), m_type(QString()), m_location(QString())
00639 {
00640
00641 }
00642
00643 KImportedBookmarkMenu::~KImportedBookmarkMenu()
00644 {
00645
00646 }
00647
00648 void KImportedBookmarkMenu::refill()
00649 {
00650
00651 }
00652
00653 void KImportedBookmarkMenu::clear()
00654 {
00655
00656 }
00657
00658
00659
00660
00661
00662
00663 void KBookmarkMenuImporter::openBookmarks( const QString &location, const QString &type )
00664 {
00665 mstack.push(m_menu);
00666
00667 KBookmarkImporterBase *importer = KBookmarkImporterBase::factory(type);
00668 if (!importer)
00669 return;
00670 importer->setFilename(location);
00671 connectToImporter(*importer);
00672 importer->parse();
00673
00674 delete importer;
00675 }
00676
00677 void KBookmarkMenuImporter::connectToImporter(const QObject &importer)
00678 {
00679 connect( &importer, SIGNAL( newBookmark( const QString &, const QString &, const QString & ) ),
00680 SLOT( newBookmark( const QString &, const QString &, const QString & ) ) );
00681 connect( &importer, SIGNAL( newFolder( const QString &, bool, const QString & ) ),
00682 SLOT( newFolder( const QString &, bool, const QString & ) ) );
00683 connect( &importer, SIGNAL( newSeparator() ), SLOT( newSeparator() ) );
00684 connect( &importer, SIGNAL( endFolder() ), SLOT( endFolder() ) );
00685 }
00686
00687 void KBookmarkMenuImporter::newBookmark( const QString & text, const QString & url, const QString & )
00688 {
00689 KBookmark bm = KBookmark::standaloneBookmark(text, url, QString("html"));
00690 KAction * action = new KBookmarkAction(bm, mstack.top()->owner(), this);
00691 mstack.top()->parentMenu()->addAction(action);
00692 mstack.top()->m_actions.append( action );
00693 }
00694
00695 void KBookmarkMenuImporter::newFolder( const QString & text, bool, const QString & )
00696 {
00697 QString _text = KStringHandler::csqueeze(text).replace( '&', "&&" );
00698 KActionMenu * actionMenu = new KImportedBookmarkActionMenu( KIcon("folder"), _text, this );
00699 mstack.top()->parentMenu()->addAction(actionMenu);
00700 mstack.top()->m_actions.append( actionMenu );
00701 KImportedBookmarkMenu *subMenu = new KImportedBookmarkMenu( m_pManager, m_menu->owner(), actionMenu->menu());
00702 mstack.top()->m_lstSubMenus.append( subMenu );
00703
00704 mstack.push(subMenu);
00705 }
00706
00707 void KBookmarkMenuImporter::newSeparator()
00708 {
00709 mstack.top()->parentMenu()->addSeparator();
00710 }
00711
00712 void KBookmarkMenuImporter::endFolder()
00713 {
00714 mstack.pop();
00715 }
00716
00717
00718
00719
00720
00721
00722 KBookmarkAction::KBookmarkAction(const KBookmark &bk, KBookmarkOwner* owner, QObject *parent )
00723 : KAction( bk.text().replace('&', "&&"), parent),
00724 KBookmarkActionInterface(bk),
00725 m_pOwner(owner)
00726 {
00727 setIcon(KIcon(bookmark().icon()));
00728 setHelpText( bookmark().url().pathOrUrl() );
00729 connect(this, SIGNAL( triggered(Qt::MouseButtons, Qt::KeyboardModifiers) ),
00730 SLOT( slotSelected(Qt::MouseButtons, Qt::KeyboardModifiers) ));
00731 }
00732
00733 KBookmarkAction::~KBookmarkAction()
00734 {
00735 }
00736
00737 void KBookmarkAction::slotSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers km)
00738 {
00739 if( !m_pOwner )
00740 new KRun( bookmark().url() ,(QWidget*)0);
00741 else
00742 m_pOwner->openBookmark( bookmark(), mb, km );
00743 }
00744
00745 KBookmarkActionMenu::KBookmarkActionMenu(const KBookmark &bm, QObject *parent)
00746 : KActionMenu(KIcon(bm.icon()), bm.text().replace('&', "&&"), parent),
00747 KBookmarkActionInterface(bm)
00748 {
00749 }
00750
00751 KBookmarkActionMenu::KBookmarkActionMenu(const KBookmark &bm, const QString & text, QObject *parent)
00752 : KActionMenu(text, parent),
00753 KBookmarkActionInterface(bm)
00754 {
00755 }
00756
00757 KBookmarkActionMenu::~KBookmarkActionMenu()
00758 {
00759 }
00760
00761 #include "kbookmarkmenu.moc"
00762 #include "kbookmarkmenu_p.moc"