+ // Get the index model.
+ const QAbstractItemModel *modelIndexAbstractItemPointer = parentModelIndex.model();
+
+ // Get the number of items in the folder.
+ int numberOfChildrenInFolder = modelIndexAbstractItemPointer->rowCount(parentModelIndex);
+
+ // Select any child items.
+ if (numberOfChildrenInFolder > 0)
+ {
+ // Select the contents of any subfolders.
+ for (int i = 0; i < numberOfChildrenInFolder; ++i)
+ {
+ // Get the child model index.
+ QModelIndex childModelIndex = modelIndexAbstractItemPointer->index(i, 0, parentModelIndex);
+
+ // Select the subfolder contents if it is a folder.
+ if (childModelIndex.siblingAtColumn(IS_FOLDER_COLUMN).data().toBool())
+ selectSubfolderContents(childModelIndex);
+ }
+
+ // 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()
+{
+ // 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();
+ }
+