From 883d2f517fe0aaab83d820e1413edffc1471bb4e Mon Sep 17 00:00:00 2001 From: skyhusker Date: Sun, 24 Apr 2005 17:50:42 +0000 Subject: Sort applications alphabetically. Fixes bug #1476. --- (limited to 'core/launcher') diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index 66f665f..ce7840e 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp @@ -67,6 +67,7 @@ StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) useWidePopupMenu = true; launchMenu = 0; + currentItem = 0; refreshMenu(); } @@ -150,11 +151,21 @@ void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file ) test.convertFromImage( img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 ); - + + // Insert items ordered lexically + int current, left = 0, right = currentItem; + while( left != right ) { + current = ( left + right ) / 2; + if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() ) + left = ++current; + else + right = current; + } + menu->insertItem( test, applnk->name(), - currentItem + APPLNK_ID_OFFSET ); - appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk ); - currentItem++; + currentItem + APPLNK_ID_OFFSET, current ); + appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk ); + currentItem++; } } -- cgit v0.9.0.2