+void BrowserWindow::populateBookmarks()
+{
+ // Remove all the current menu bookmarks.
+ for (QAction *bookmarkAction : bookmarksMenuCurrentActionList)
+ {
+ // Remove the bookmark.
+ bookmarksMenuPointer->removeAction(bookmarkAction);
+ }
+
+ // Remove all the current toolbar bookmarks.
+ for (QAction *bookmarkAction : bookmarksToolBarCurrentActionList)
+ {
+ // Remove the bookmark.
+ bookmarksToolBarPointer->removeAction(bookmarkAction);
+ }
+
+ // Clear the current bookmark lists.
+ bookmarksMenuCurrentActionList.clear();
+ bookmarksToolBarCurrentActionList.clear();
+
+ // Get a list of the bookmarks.
+ std::list<BookmarkStruct> *bookmarkListPointer = BookmarksDatabase::getBookmarks();
+
+ // Populate the bookmarks menu.
+ for (BookmarkStruct bookmarkStruct : *bookmarkListPointer)
+ {
+ // Get the bookmark URL.
+ QString bookmarkUrl = bookmarkStruct.bookmarkUrl;
+
+ // Add the bookmark to the menu.
+ QAction *menuBookmarkActionPointer = bookmarksMenuPointer->addAction(bookmarkStruct.favoriteIcon, bookmarkStruct.bookmarkName, [=]
+ {
+ // Remove the focus from the URL line edit.
+ urlLineEditPointer->clearFocus();
+
+ // Load the URL.
+ tabWidgetPointer->loadUrlFromLineEdit(bookmarkUrl);
+ }
+ );
+
+ // Add the bookmark to the toolbar.
+ QAction *toolBarBookmarkActionPointer = bookmarksToolBarPointer->addAction(bookmarkStruct.favoriteIcon, bookmarkStruct.bookmarkName, [=]
+ {
+ // Remove the focus from the URL line edit.
+ urlLineEditPointer->clearFocus();
+
+ // Load the URL.
+ tabWidgetPointer->loadUrlFromLineEdit(bookmarkUrl);
+ }
+ );
+
+ // Add the actions to the current bookmarks lists.
+ bookmarksMenuCurrentActionList.append(menuBookmarkActionPointer);
+ bookmarksToolBarCurrentActionList.append(toolBarBookmarkActionPointer);
+ }
+
+ // Get a handle for the bookmark toolbar layout.
+ QLayout *bookmarksToolBarLayoutPointer = bookmarksToolBarPointer->layout();
+
+ // Get the count of the bookmarks.
+ int bookmarkCount = bookmarksToolBarLayoutPointer->count();
+
+ // Set the layout of each bookmark to be left aligned.
+ for(int i = 0; i < bookmarkCount; ++i)
+ bookmarksToolBarLayoutPointer->itemAt(i)->setAlignment(Qt::AlignLeft);
+}
+