-
Notifications
You must be signed in to change notification settings - Fork 46
fix: Dragging applications in application folder cannot create a new page #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -153,10 +153,22 @@ void ItemArrangementProxyModel::commitDndOperation(const QString &dragId, const | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // return new empty page index | ||||||||||||
| int ItemArrangementProxyModel::creatEmptyPage() const | ||||||||||||
| int ItemArrangementProxyModel::creatEmptyPage(int folderId) const | ||||||||||||
| { | ||||||||||||
| m_topLevel->appendEmptyPage(); | ||||||||||||
| return m_topLevel->pageCount() - 1; | ||||||||||||
| if(folderId == 0){ | ||||||||||||
| m_topLevel->appendEmptyPage(); | ||||||||||||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Using 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.
Suggested change
|
||||||||||||
|
|
||||||||||||
| if (auto itemPage = m_folders.value(fullId); itemPage) { | ||||||||||||
| itemPage->appendEmptyPage(); | ||||||||||||
| return itemPage->pageCount() - 1; | ||||||||||||
| } else { | ||||||||||||
| qWarning() << "itemPage create empty page false, return 0. fullId is" << fullId; | ||||||||||||
| return 0; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| void ItemArrangementProxyModel::removeEmptyPage() const | ||||||||||||
|
|
@@ -408,6 +420,11 @@ ItemsPage *ItemArrangementProxyModel::createFolder(const QString &id) | |||||||||||
| folder->setData(fullId, AppItem::DesktopIdRole); | ||||||||||||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Hard-coded index for parsing Store the numeric ID separately or derive it with split/regex rather than relying on a hard-coded offset. |
||||||||||||
| emit folderPageCountChanged(folderId); | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| return page; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,7 @@ class ItemArrangementProxyModel : public QConcatenateTablesProxyModel | |
| Q_INVOKABLE void updateFolderName(int folderId, const QString & name); | ||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Method name typo and const correctness Rename |
||
| Q_INVOKABLE void removeEmptyPage() const; | ||
|
|
||
| ItemsPage *itemsPage() { return m_topLevel; } | ||
|
|
@@ -70,6 +70,7 @@ class ItemArrangementProxyModel : public QConcatenateTablesProxyModel | |
|
|
||
| signals: | ||
| void topLevelPageCountChanged(); | ||
| void folderPageCountChanged(int folderId); | ||
|
|
||
| private: | ||
| explicit ItemArrangementProxyModel(QObject *parent = nullptr); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.