author | skyhusker <skyhusker> | 2005-04-24 17:50:42 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-04-24 17:50:42 (UTC) |
commit | 883d2f517fe0aaab83d820e1413edffc1471bb4e (patch) (side-by-side diff) | |
tree | dc7255faf24d909bf0ca8f0afc05202459615414 | |
parent | ceaea9869115287b48781fabc938bd51cb67625c (diff) | |
download | opie-883d2f517fe0aaab83d820e1413edffc1471bb4e.zip opie-883d2f517fe0aaab83d820e1413edffc1471bb4e.tar.gz opie-883d2f517fe0aaab83d820e1413edffc1471bb4e.tar.bz2 |
Sort applications alphabetically. Fixes bug #1476.
-rw-r--r-- | core/launcher/startmenu.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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 @@ -58,24 +58,25 @@ void StartPopupMenu::keyPressEvent( QKeyEvent *e ) StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
{
startButtonPixmap = "go"; // No tr
int sz = AppLnk::smallIconSize()+3;
QPixmap pm;
pm.convertFromImage(Resource::loadImage( startButtonPixmap).smoothScale( sz,sz) );
setPixmap(pm);
setFocusPolicy( NoFocus );
useWidePopupMenu = true;
launchMenu = 0;
+ currentItem = 0;
refreshMenu();
}
void StartMenu::mousePressEvent( QMouseEvent * )
{
launch();
}
StartMenu::~StartMenu()
{
@@ -142,26 +143,36 @@ void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file ) if ( applnk->type() == "Separator" ) { // No tr
menu->insertSeparator();
delete applnk;
} else {
QPixmap test;
QImage img = Resource::loadImage( applnk->icon() );
if(!img.isNull() )
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 );
+ currentItem + APPLNK_ID_OFFSET, current );
appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk );
currentItem++;
}
}
}
void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot )
{
// do some sanity checks and collect information
if ( file == "." || file == ".." ) return;
|