Skip to content

Commit 4520c31

Browse files
wjyrichBLumia
authored andcommitted
fix: app will automatically fill in from the first page of folder
as title. PMS-BUG-288821
1 parent 0e85c7a commit 4520c31

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

src/models/itemspage.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,31 @@ void ItemsPage::insertItem(const QString id, int page, int pos)
146146

147147
void ItemsPage::insertItemToPage(const QString &id, int toPage)
148148
{
149+
if (toPage < 0) {
150+
// 从第一页开始查找有空位的页面进行自动补位
151+
const int pageCount = m_pages.count();
152+
toPage = -1; // 标记未找到空位
153+
154+
for (int page = 0; page < pageCount; page++) {
155+
if (m_pages.at(page).size() < m_maxItemCountPerPage) {
156+
toPage = page;
157+
break;
158+
}
159+
}
160+
161+
// 如果没有找到空位,创建新页面
162+
if (toPage == -1) {
163+
appendPage({id});
164+
return;
165+
}
166+
}
167+
168+
if (m_pages.count() == 0) {
169+
appendPage({id});
170+
return;
171+
}
149172
Q_ASSERT(toPage < m_pages.count());
150173

151-
if (toPage < 0) toPage = qMax(m_pages.count() - 1, 0);
152-
153174
insertItem(id, toPage, m_pages[toPage].count());
154175
}
155176

0 commit comments

Comments
 (0)