Version: 1.2 (using KDE 3.1.9) Compiler: gcc version 3.3 20030226 (prerelease) (SuSE Linux) OS: Linux (i686) release 2.4.20-4GB Hi! IMHO it would be great if the "old" possibility "Add bookmark here" could co-exist with the current solution. I found it very useful to "see" what's _in_ the folder and not only the folder. This also avoids to add the same entry twice. (weak argument though) cu ferdinand
Subject: kdelibs/kio/bookmarks CVS commit by lypanov: add "Insert Bookmark" and "Insert Bookmark Here" to the bookmark menu context menu CCMAIL:57938-close@bugs.kde.org M +43 -0 kbookmarkmenu.cc 1.174 M +1 -0 kbookmarkmenu.h 1.61 --- kdelibs/kio/bookmarks/kbookmarkmenu.cc #1.173:1.174 @@ -224,4 +224,5 @@ void KBookmarkMenu::slotActionHighlighte } +// change to static non method bool KBookmarkMenu::invalid( int val ) { @@ -264,5 +265,8 @@ void KBookmarkMenu::fillContextMenu( QPo id = contextMenu->insertItem( i18n( "Delete Folder" ), this, SLOT(slotRMBActionRemove(int)) ); contextMenu->setItemParameter( id, val ); + id = contextMenu->insertItem( i18n( "Insert Bookmark" ), this, SLOT(slotRMBActionInsert(int)) ); + contextMenu->setItemParameter( id, val ); // contextMenu->insertItem( i18n( "Properties" ), this, SLOT(slotRMBActionProperties(int)) ); + // contextMenu->setItemParameter( id, val ); } else @@ -274,4 +278,6 @@ void KBookmarkMenu::fillContextMenu( QPo id = contextMenu->insertItem( i18n( "Open Bookmark" ), this, SLOT(slotRMBActionOpen(int)) ); contextMenu->setItemParameter( id, val ); + id = contextMenu->insertItem( i18n( "Insert Bookmark Here" ), this, SLOT(slotRMBActionInsert(int)) ); + contextMenu->setItemParameter( id, val ); } @@ -288,4 +294,41 @@ void KBookmarkMenu::slotRMBActionEditAt( emit m_pManager->slotEditBookmarksAtAddress( s_highlightedAddress ); +} + +void KBookmarkMenu::slotRMBActionInsert( int val ) +{ + kdDebug(7043) << "KBookmarkMenu::slotRMBActionInsert" << s_highlightedAddress << endl; + if (invalid(val)) return; + + QString url = m_pOwner->currentURL(); + if (url.isEmpty()) + { + KMessageBox::error( 0L, i18n("Can't add bookmark with empty URL")); + return; + } + QString title = m_pOwner->currentTitle(); + if (title.isEmpty()) + title = url; + + KBookmark bookmark = m_pManager->findByAddress( s_highlightedAddress ); + Q_ASSERT(!bookmark.isNull()); + + // TODO use unique title + + if (bookmark.isGroup()) + { + KBookmarkGroup parentBookmark = bookmark.toGroup(); + Q_ASSERT(!parentBookmark.isNull()); + parentBookmark.addBookmark( m_pManager, title, url ); + m_pManager->emitChanged( parentBookmark ); + } + else + { + KBookmarkGroup parentBookmark = bookmark.parentGroup(); + Q_ASSERT(!parentBookmark.isNull()); + KBookmark newBookmark = parentBookmark.addBookmark( m_pManager, title, url ); + parentBookmark.moveItem( newBookmark, parentBookmark.previous(bookmark) ); + m_pManager->emitChanged( parentBookmark ); + } } --- kdelibs/kio/bookmarks/kbookmarkmenu.h #1.60:1.61 @@ -163,4 +163,5 @@ protected slots: void slotRMBActionRemove( int ); + void slotRMBActionInsert( int ); void slotRMBActionOpen( int ); void slotRMBActionCopyLocation( int );