+ // Get the first and last child model indexes.
+ QModelIndex firstChildModelIndex = modelIndexAbstractItemPointer->index(0, 0, parentModelIndex);
+ QModelIndex lastChildModelIndex = modelIndexAbstractItemPointer->index((numberOfChildrenInFolder - 1), 0, parentModelIndex);
+
+ // Create an item selection that includes all the child items.
+ QItemSelection folderChildItemsSelection = QItemSelection(firstChildModelIndex, lastChildModelIndex);
+
+ // Get the current selection.
+ QItemSelection currentSelection = treeSelectionModelPointer->selection();
+
+ // Combine the current selection and the folder child items selection.
+ currentSelection.merge(folderChildItemsSelection, QItemSelectionModel::SelectCurrent);
+
+ // Selected the updated list of items.
+ treeSelectionModelPointer->select(currentSelection, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+ }
+}
+
+void BookmarksDialog::showAddBookmarkDialog() const
+{
+ // Return the most recently selected index.
+ QModelIndex currentIndex = treeSelectionModelPointer->currentIndex();
+
+ // Instantiate a parent folder ID.
+ double parentFolderId;
+
+ // Get the parent folder ID.
+ if (currentIndex.siblingAtColumn(IS_FOLDER_COLUMN).data().toInt() == 1) // The current index is a folder.
+ {
+ // Store the parent folder ID.
+ parentFolderId = currentIndex.siblingAtColumn(FOLDER_ID_COLUMN).data().toDouble();
+ }
+ else // The current index is not a folder.
+ {
+ // Store the parent folder ID of the folder that contains the bookmark.
+ parentFolderId = currentIndex.parent().siblingAtColumn(FOLDER_ID_COLUMN).data().toDouble();
+ }
+
+ // Instantiate an add bookmark dialog.
+ AddBookmarkDialog *addBookmarkDialogPointer = new AddBookmarkDialog(websiteTitle, websiteUrl, websiteFavoriteIcon, parentFolderId);
+
+ // Update the displayed bookmarks when a new one is added.
+ connect(addBookmarkDialogPointer, SIGNAL(bookmarkAdded()), this, SLOT(refreshBookmarks()));
+
+ // Show the dialog.
+ addBookmarkDialogPointer->show();
+}
+
+void BookmarksDialog::showAddFolderDialog() const
+{
+ // Get the most recently selected index.
+ QModelIndex currentIndex = treeSelectionModelPointer->currentIndex();
+
+ // Instantiate a parent folder ID.
+ double parentFolderId;
+
+ // Get the parent folder ID.
+ if (currentIndex.siblingAtColumn(IS_FOLDER_COLUMN).data().toInt() == 1) // The current index is a folder.
+ {
+ // Store the parent folder ID.
+ parentFolderId = currentIndex.siblingAtColumn(FOLDER_ID_COLUMN).data().toDouble();
+ }
+ else // The current index is not a folder.
+ {
+ // Store the parent folder ID of the folder that contains the bookmark.
+ parentFolderId = currentIndex.parent().siblingAtColumn(FOLDER_ID_COLUMN).data().toDouble();
+ }
+
+ // Instantiate an add folder dialog.
+ AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(websiteFavoriteIcon, parentFolderId);
+
+ // Update the displayed bookmarks when a folder is added.
+ connect(addFolderDialogPointer, SIGNAL(folderAdded()), this, SLOT(refreshBookmarks()));
+
+ // Show the dialog.
+ addFolderDialogPointer->show();
+}
+
+void BookmarksDialog::showEditDialog()
+{
+ // Get the current model index.
+ QModelIndex currentIndex = treeSelectionModelPointer->currentIndex();
+
+ // Check to see if the selected item is a folder.
+ if (currentIndex.siblingAtColumn(IS_FOLDER_COLUMN).data().toInt() == 1) // The selected item is a folder.
+ {
+ // Instantiate an edit folder dialog.
+ QDialog *editFolderDialogPointer = new EditFolderDialog(currentIndex.siblingAtColumn(DATABASE_ID_COLUMN).data().toInt(), websiteFavoriteIcon);
+
+ // Show the dialog.
+ editFolderDialogPointer->show();
+
+ // Update the bookmarks UI.
+ connect(editFolderDialogPointer, SIGNAL(folderSaved()), this, SLOT(refreshBookmarks()));
+ }
+ else // The selected item is a bookmark.
+ {
+ // Instantiate an edit bookmark dialog.
+ QDialog *editBookmarkDialogPointer = new EditBookmarkDialog(currentIndex.siblingAtColumn(DATABASE_ID_COLUMN).data().toInt(), websiteFavoriteIcon);
+
+ // Show the dialog.
+ editBookmarkDialogPointer->show();
+
+ // Update the bookmarks UI.
+ connect(editBookmarkDialogPointer, SIGNAL(bookmarkSaved()), this, SLOT(refreshBookmarks()));
+ }