fix: Dragging applications in application folder cannot create a new page#558
Conversation
deepin pr auto review代码审查意见:
|
Reviewer's GuideThis PR enhances the folder drag-and-drop experience by creating new empty pages on demand when dragging past the last page in a folder and propagates folder-specific page count updates to the QML view. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @wjyrich - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| Q_INVOKABLE void bringToFront(const QString & id); | ||
| Q_INVOKABLE void commitDndOperation(const QString & dragId, const QString & dropId, const DndOperation op, int pageHint = -1); | ||
| Q_INVOKABLE int creatEmptyPage() const; | ||
| Q_INVOKABLE int creatEmptyPage(int folderId = 0) const; |
There was a problem hiding this comment.
suggestion: Method name typo and const correctness
Rename creatEmptyPage to createEmptyPage for clarity, and drop the const qualifier since this method mutates internal state.
| return m_topLevel->pageCount() - 1; | ||
| } | ||
| QString fullId("internal/folders/" + QString::number(folderId)); | ||
| Q_ASSERT(m_folders.contains(fullId)); |
There was a problem hiding this comment.
suggestion: Using Q_ASSERT here may abort in debug builds
Replace the assert with a runtime check—since you already warn and return on missing folders—to avoid debug-only aborts and keep behavior consistent.
| Q_ASSERT(m_folders.contains(fullId)); | |
| if (!m_folders.contains(fullId)) { | |
| qWarning() << "Folder not found, returning 0. fullId is" << fullId; | |
| return 0; | |
| } |
| m_folderModel.appendRow(folder); | ||
|
|
||
| connect(page, &ItemsPage::pageCountChanged, this, [this, fullId]() { | ||
| int folderId = QStringView{fullId}.mid(17).toInt(); |
There was a problem hiding this comment.
suggestion: Hard-coded index for parsing folderId is brittle
Store the numeric ID separately or derive it with split/regex rather than relying on a hard-coded offset.
…new page as title. pms-bug-288839
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
as title.
pms-bug-288839
Summary by Sourcery
Enable dynamic creation of new pages within application folders by dragging items to the folder’s edge and update the page indicator when the folder’s page count changes.
Bug Fixes:
Enhancements:
createdEmptyPageflag in QML to prevent duplicate page creation during drag operations.ItemArrangementProxyModel::creatEmptyPageto accept a folder ID and handle folder-specific page creation.folderPageCountChangedfrom the proxy model and update the QMLgridViewsrepeater model when a folder’s page count changes.createdEmptyPageflag after completing a drop operation.