File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -363,7 +363,27 @@ void ItemArrangementProxyModel::onSourceModelChanged()
363363 // add all existing ones if they are not already in
364364 if (folder == -1 ) {
365365 findItem (desktopId);
366- m_topLevel->appendItem (desktopId);
366+ // Find first available page with space
367+ int targetPage = -1 ;
368+ int targetIndex = -1 ;
369+
370+ // Check each page for available space
371+ for (int page = 0 ; page < m_topLevel->pageCount (); page++) {
372+ int itemCount = m_topLevel->itemCount (page);
373+ if (itemCount < m_topLevel->maxItemCountPerPage ()) {
374+ targetPage = page;
375+ targetIndex = itemCount;
376+ break ;
377+ }
378+ }
379+
380+ if (targetPage != -1 ) {
381+ // Add to first available page with space
382+ m_topLevel->insertItem (desktopId, targetPage, targetIndex);
383+ } else {
384+ // All pages are full, append to new page
385+ m_topLevel->appendItem (desktopId);
386+ }
367387 }
368388 }
369389
You can’t perform that action at this time.
0 commit comments