QDialogButtonBox *dialogButtonBoxPointer = editFolderDialogUi.dialogButtonBox;
saveButtonPointer = dialogButtonBoxPointer->button(QDialogButtonBox::Save);
- // Get the bookmark struct.
- bookmarkStructPointer = BookmarksDatabase::getBookmark(databaseId);
+ // Get the folder bookmark struct.
+ folderBookmarkStructPointer = BookmarksDatabase::getBookmark(databaseId);
// Set the folder icons.
- currentFolderIconRadioButtonPointer->setIcon(bookmarkStructPointer->favoriteIcon);
+ currentFolderIconRadioButtonPointer->setIcon(folderBookmarkStructPointer->favoriteIcon);
currentWebsiteFavoriteIconRadioButtonPointer->setIcon(currentWebsiteFavoriteIcon);
// Instantiate a folder helper.
parentFolderTreeWidgetPointer->addTopLevelItem(bookmarksTreeWidgetItemPointer);
// Select the root bookmarks folder if it is the initial parent folder.
- if (bookmarkStructPointer->parentFolderId == 0)
+ if (folderBookmarkStructPointer->parentFolderId == 0)
bookmarksTreeWidgetItemPointer->setSelected(true);
// Populate the subfolders, except for the one being edited.
- folderHelperPointer->populateSubfoldersExcept(databaseId, bookmarksTreeWidgetItemPointer, bookmarkStructPointer->parentFolderId);
+ folderHelperPointer->populateSubfoldersExcept(databaseId, bookmarksTreeWidgetItemPointer, folderBookmarkStructPointer->parentFolderId);
// Open all the folders.
parentFolderTreeWidgetPointer->expandAll();
// Populate the line edits.
- folderNameLineEditPointer->setText(bookmarkStructPointer->name);
+ folderNameLineEditPointer->setText(folderBookmarkStructPointer->name);
// Focus the folder name line edit.
folderNameLineEditPointer->setFocus();
// Get the parent folder ID.
double parentFolderId = selectedFolderPointer->text(folderHelperPointer->FOLDER_ID_COLUMN).toDouble();
+ // Determine if it has moved to a new folder.
+ bool movedToNewFolder = parentFolderId != folderBookmarkStructPointer->parentFolderId;
+
// Get the original display order.
- int displayOrder = bookmarkStructPointer->displayOrder;
+ int displayOrder = folderBookmarkStructPointer->displayOrder;
// Get the new display order if the parent folder has changed.
- if (parentFolderId != bookmarkStructPointer->parentFolderId)
+ if (movedToNewFolder)
displayOrder = BookmarksDatabase::getFolderItemCount(parentFolderId);
// Create a favorite icon.
// Update the folder.
BookmarksDatabase::updateBookmark(updatedBookmarkStructPointer);
- // Update the display order of all the items in the previous folder.
- BookmarksDatabase::updateFolderContentsDisplayOrder(bookmarkStructPointer->parentFolderId);
+ // Update the display order of all the items in the previous folder if it has moved to a new folder.
+ if (movedToNewFolder)
+ BookmarksDatabase::updateFolderContentsDisplayOrder(folderBookmarkStructPointer->parentFolderId);
// Emit the folder saved signal.
emit folderSaved();
FolderHelper *folderHelperPointer;
// The private widgets.
- BookmarkStruct *bookmarkStructPointer;
QRadioButton *currentFolderIconRadioButtonPointer;
QRadioButton *currentWebsiteFavoriteIconRadioButtonPointer;
QRadioButton *customFolderIconRadioButtonPointer;
+ BookmarkStruct *folderBookmarkStructPointer;
int folderDatabaseId;
QLineEdit *folderNameLineEditPointer;
QTreeWidget *parentFolderTreeWidgetPointer;
/*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// Populate each subfolder.
for (BookmarkStruct bookmarkStruct : *subfoldersList)
{
- // Only populate the subfolder if it is not excepted.
- if (bookmarkStruct.databaseId != exceptSubfolderDatabaseId)
- {
- // Create a tree widget item.
- QTreeWidgetItem *subfolderWidgetItemPointer = new QTreeWidgetItem();
-
- // Populate the tree widget item.
- subfolderWidgetItemPointer->setText(FOLDER_NAME_COLUMN, bookmarkStruct.name);
- subfolderWidgetItemPointer->setIcon(FOLDER_NAME_COLUMN, bookmarkStruct.favoriteIcon);
- subfolderWidgetItemPointer->setText(FOLDER_ID_COLUMN, QString::number(bookmarkStruct.folderId, 'f', 0)); // Format the folder ID as a floating point with no trailing zeros.
-
- // Add the subfolder to the tree widget item.
- treeWidgetItemPointer->addChild(subfolderWidgetItemPointer);
-
- // Select the folder if it is the initial parent folder.
- if (bookmarkStruct.folderId == initialParentFolderId)
- subfolderWidgetItemPointer->setSelected(true);
-
- // Add any subfolders.
- populateSubfoldersExcept(exceptSubfolderDatabaseId, subfolderWidgetItemPointer, initialParentFolderId);
- }
+ // Determine if this is an excepted folder.
+ bool exceptedFolder = bookmarkStruct.databaseId == exceptSubfolderDatabaseId;
+
+ // Create a tree widget item.
+ QTreeWidgetItem *subfolderWidgetItemPointer = new QTreeWidgetItem();
+
+ // Populate the tree widget item.
+ subfolderWidgetItemPointer->setText(FOLDER_NAME_COLUMN, bookmarkStruct.name);
+ subfolderWidgetItemPointer->setIcon(FOLDER_NAME_COLUMN, bookmarkStruct.favoriteIcon);
+ subfolderWidgetItemPointer->setText(FOLDER_ID_COLUMN, QString::number(bookmarkStruct.folderId, 'f', 0)); // Format the folder ID as a floating point with no trailing zeros.
+
+ // Disable the folder widget if it is excepted. All subfolders will automatically be disabled.
+ if (exceptedFolder)
+ subfolderWidgetItemPointer->setDisabled(true);
+
+ // Add the subfolder to the tree widget item.
+ treeWidgetItemPointer->addChild(subfolderWidgetItemPointer);
+
+ // Select the folder if it is the initial parent folder.
+ if (bookmarkStruct.folderId == initialParentFolderId)
+ subfolderWidgetItemPointer->setSelected(true);
+
+ // Add any subfolders.
+ populateSubfoldersExcept(exceptSubfolderDatabaseId, subfolderWidgetItemPointer, initialParentFolderId);
}
}