[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Tue Mar 9 15:47:55 CET 2004


CVS commit by harris: 

Improving usability of find dialog.  Up/Down arrow keys now adjust 
selected object up/down.  Enter key now accepts selected object, 
and closes the window.

CCMAIL: kstars-devel at kde.org


  M +19 -2     finddialog.cpp   1.22
  M +20 -18    finddialog.h   1.9


--- kdeedu/kstars/kstars/finddialog.h  #1.8:1.9
@@ -48,7 +48,7 @@ class QStringList;
 
 class FindDialog : public KDialogBase  {
-        Q_OBJECT
+Q_OBJECT
         
-        public:
+public:
 /**
         *Constructor. Creates all widgets and packs them in QLayouts.  Connects
@@ -67,6 +67,8 @@ class FindDialog : public KDialogBase  {
         SkyObjectNameListItem * currentItem() const { return currentitem; }
         
-        private:
+protected:
+        void keyPressEvent( QKeyEvent *e );
 
+private:
                 QVBoxLayout *vlay;
                 QHBoxLayout *hlay;

--- kdeedu/kstars/kstars/finddialog.cpp  #1.21:1.22
@@ -84,6 +84,7 @@ FindDialog::FindDialog( QWidget* parent 
         connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
         connect( SearchBox, SIGNAL( textChanged( const QString & ) ), SLOT( filter() ) );
+        connect( SearchBox, SIGNAL( returnPressed() ), SLOT( slotOk() ) );
         connect( filterType, SIGNAL( activated( int ) ), this, SLOT( setFilter( int ) ) );
-        connect (SearchList, SIGNAL (selectionChanged  (QListBoxItem *)), SLOT (updateSelection (QListBoxItem *)));
+        connect( SearchList, SIGNAL (selectionChanged  (QListBoxItem *)), SLOT (updateSelection (QListBoxItem *)));
         connect( SearchList, SIGNAL( doubleClicked ( QListBoxItem *  ) ), SLOT( slotOk() ) );
 
@@ -198,3 +199,19 @@ void FindDialog::slotOk() {
         }
 }
+
+void FindDialog::keyPressEvent( QKeyEvent *e ) {
+        switch( e->key() ) {
+                case Key_Down :
+                        if ( SearchList->currentItem() < SearchList->count() - 1 )
+                                SearchList->setCurrentItem( SearchList->currentItem() + 1 );
+                        break;
+                        
+                case Key_Up :
+                        if ( SearchList->currentItem() > 0 )
+                                SearchList->setCurrentItem( SearchList->currentItem() - 1 );
+                        break;
+                        
+        }
+}
+
 #include "finddialog.moc"




More information about the Kstars-devel mailing list