Bug 57938 - add bookmarks reenable previous logic
Summary: add bookmarks reenable previous logic
Status: RESOLVED FIXED
Alias: None
Product: keditbookmarks
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: lypanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-01 10:51 UTC by Ferdinand Gassauer
Modified: 2003-05-01 15:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ferdinand Gassauer 2003-05-01 10:51:04 UTC
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
Comment 1 lypanov 2003-05-01 15:29:21 UTC
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 );