Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding history and bookmarks to browser
QtWS25 Last Chance

Adding history and bookmarks to browser

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicky j
    wrote on 19 Jan 2014, 01:54 last edited by
    #1

    Hello everyone,

    I have reached a point in developing my browser where I would like to add history and bookmark functionality.
    I would like the URL of the webpage to be written into a text file, the first ten entries in this text file would be created as QActions that will automatically appear under the 'history' menu. I basically need my browser to read and write to a text file. I also would like to have a 'clear history' QAction that deletes all the contents of the text file.
    How can I make my browser save every web page I visit as an entry in a text file, and also create the first 10 entries as QActions that take me to that entries URL?
    I figure that once I have this method of doing the history down, I can do something similar to make bookmarks.

    Example code would be great!

    Thank you!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dcortesi
      wrote on 19 Jan 2014, 18:39 last edited by
      #2

      I am puzzled why a text file particularly? It seems to me that while the browser is running you would want to keep your history in memory, as a list (QLinkedList?) or array. And then when you are closing down you can write the current history into the settings, and when starting up, retrieve the history list from the settings. QSettings provides for reading and writing "arrays" of similar items, which would be very handy for a list of QUrls, I would think.

      Using settings removes many complications like "where did the user save the history file" and "suppose the history file was erased or renamed between sessions" etc.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicky j
        wrote on 19 Jan 2014, 21:41 last edited by
        #3

        Alright, I'm a newbie and I think your approach sounds better! How would I do it? Could you maybe provide some example code?
        Thanks a ton!

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dcortesi
          wrote on 19 Jan 2014, 22:35 last edited by
          #4

          You are a "newbie" and you are writing a browser? Oooookayyyy... well it's a way to learn. As to example code, I don't write in C++ but rather Python. If you can read Python take a look at one pet project, which is kind of a browser also: "Cobro":https://github.com/tallforasmurf/CoBro and read the readme.

          In cobro.py, scroll down to "line 1661":https://github.com/tallforasmurf/CoBro/blob/master/cobro.py#L1661 (holy crap that got to be a big program...) where the QSettings is initialized.

          At "line 1391":https://github.com/tallforasmurf/CoBro/blob/master/cobro.py#L1391 is where the main window recovers its window geometry from the settings. At line 1652 is where the main window saves its current geometry for next time.

          At "line 914":https://github.com/tallforasmurf/CoBro/blob/master/cobro.py#L914 is where the list model loads itself from an array in settings. Just above it is the code to save the list contents back into settings at shutdown.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nicky j
            wrote on 20 Jan 2014, 00:00 last edited by
            #5

            okay I understand what you did there, but I'm not sure how to implement that in Qt C++.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dcortesi
              wrote on 20 Jan 2014, 00:28 last edited by
              #6

              Same class names, same method names, same sequence of operations. If you can see about what it's doing, just look up anything that starts with Q in the Qt Assistant and go from there.

              1 Reply Last reply
              0

              2/6

              19 Jan 2014, 18:39

              topic:navigator.unread, 4
              • Login

              • Login or register to search.
              2 out of 6
              • First post
                2/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved