Bug 124082 - remember and suggest the last visited address
Summary: remember and suggest the last visited address
Status: RESOLVED FIXED
Alias: None
Product: krdc
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Urs Wolfer
URL:
Keywords:
: 125872 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-22 15:58 UTC by Maciej Pilichowski
Modified: 2007-08-07 22:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
krdc.diff.gz (1.28 KB, patch)
2006-04-26 20:38 UTC, Maciej Pilichowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Pilichowski 2006-03-22 15:58:31 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    SuSE RPMs

...when starting Krdc.


[# ignore ignore ignore ignore ignore ignore this line #]
Comment 1 Jaison Lee 2006-03-22 17:10:01 UTC
Standard disclaimer: KRDC has been unmaintained for a VERY long time now, so the future of the program is very much uncertain.
Comment 2 Maciej Pilichowski 2006-03-22 17:18:31 UTC
Pity, it is very useful. 

Hmm, looks like "do it yourself" situation :-)))
Comment 3 Jaison Lee 2006-04-19 14:49:30 UTC
*** Bug 125872 has been marked as a duplicate of this bug. ***
Comment 4 Maciej Pilichowski 2006-04-26 20:38:20 UTC
Created attachment 15786 [details]
krdc.diff.gz

This patch _should_ /it is my first patch ;-)/ fix the reported problem + minor
one with remembering entered address on close.
Comment 5 Urs Wolfer 2007-08-07 22:07:12 UTC
SVN commit 697448 by uwolfer:

Add history folder in bookmarks. All host you have successfully connected to will be added there. This way it's easier to find an already used host.

Thanks Daniel for your inputs!

CCMAIL: Daniel Teske <teske@squorn.de>
BUG: 124082

 M  +41 -3     bookmarkmanager.cpp  
 M  +3 -0      bookmarkmanager.h  
 M  +2 -0      mainwindow.cpp  


--- trunk/KDE/kdenetwork/krdc/bookmarkmanager.cpp #697447:697448
@@ -37,17 +37,55 @@
 
     QString file = KStandardDirs::locateLocal("data", "krdc/bookmarks.xml");
 
-    KBookmarkManager *manager = KBookmarkManager::managerForFile(file, "krdc");
+    m_manager = KBookmarkManager::managerForFile(file, "krdc");
 
-    manager->setUpdate(true);
+    m_manager->setUpdate(true);
 
-    m_bookmarkMenu = new KBookmarkMenu(manager, this, m_menu, collection );
+    m_bookmarkMenu = new KBookmarkMenu(m_manager, this, m_menu, collection );
+
+    KBookmarkGroup root = m_manager->root();
+    KBookmark bm = root.first();
+    while (!bm.isNull()) {
+        if (bm.metaDataItem("krdc-history") == "historyfolder") // get it also when user renamed it
+            break;
+        bm = root.next(bm);
+    }
+
+    if(bm.isNull()) {
+        kDebug(5010) << "History folder not found. Create it.";
+        bm = m_manager->root().createNewFolder(m_manager, i18n("History"));
+        bm.setMetaDataItem("krdc-history", "historyfolder");
+    }
+
+    m_historyGroup = bm.toGroup();
 }
 
 BookmarkManager::~BookmarkManager()
 {
 }
 
+void BookmarkManager::addHistoryBookmark()
+{
+    kDebug(5010) << "addHistoryBookmark";
+
+    KBookmark bm = m_historyGroup.first();
+    while (!bm.isNull()) {
+        if (bm.url() == KUrl(currentUrl())) {
+            kDebug(5010) << "Found URL. Move it at the history start.";
+            m_historyGroup.moveItem(bm, KBookmark());
+            m_manager->emitChanged();
+            return;
+        }
+        bm = m_historyGroup.next(bm);
+    }
+
+    if(bm.isNull()) {
+        kDebug(5010) << "Add new history bookmark.";
+        m_historyGroup.moveItem(m_historyGroup.addBookmark(m_manager, currentTitle(), currentUrl()), KBookmark());
+        m_manager->emitChanged();
+    }
+}
+
 void BookmarkManager::openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers)
 {
     emit openUrl(bm.url());
--- trunk/KDE/kdenetwork/krdc/bookmarkmanager.h #697447:697448
@@ -47,6 +47,7 @@
     virtual bool editBookmarkEntry() const;
     virtual bool supportsTabs() const;
     virtual QList<QPair<QString, QString> > currentBookmarkList() const;
+    void addHistoryBookmark();
 
 signals:
     void openUrl(const KUrl &url);
@@ -57,6 +58,8 @@
 private:
     KMenu *m_menu;
     KBookmarkMenu *m_bookmarkMenu;
+    KBookmarkManager *m_manager;
+    KBookmarkGroup m_historyGroup;
 
     MainWindow *m_mainWindow;
 };
--- trunk/KDE/kdenetwork/krdc/mainwindow.cpp #697447:697448
@@ -314,6 +314,8 @@
             slotSwitchFullscreen();
         }
 
+        m_bookmarkManager->addHistoryBookmark();
+
         break;
     default:
         iconName = "krdc";