[Kstars-devel] KDE/kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Fri Sep 8 17:18:21 CEST 2006


SVN commit 582199 by harris:

Find dialog tweaks:

+ Removed incremental adding objects 1000 at a time with processEvents() 
in between.  Doing this is much slower under Qt4, with several 
noticeable "blinks" of the object list before the window is ready for 
interaction.  Removing this and simply calling 
"ui->SearchList->addItems( ObjNames )" is much faster under Qt4.  
There's still a small lag, so maybe there's still some optimization that 
can be done.

+ Sort the items in the SearchBox alphabetically

+ If there is no filter text, highlight "Andromeda Galaxy" as a default 
object.  It's a very well-known object near the top of the list.  This 
avoids highlighting some random numbered comet every time the Find 
dialog is invoked. :)

CCMAIL: kstars-devel at kde.org



 M  +20 -11    finddialog.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/finddialog.cpp #582198:582199
@@ -88,21 +88,30 @@
 		rx.setCaseSensitivity( Qt::CaseInsensitive );
 		ObjNames = p->data()->skyComposite()->objectNames().filter(rx);
 	}
+	ObjNames.sort();
 
-	if ( ObjNames.size() ) {
-		if ( ObjNames.size() > 5000) {
-			int index=0;
-			while ( index+1000 < ObjNames.size() ) {
-				ui->SearchList->addItems( ObjNames.mid( index, 1000 ) );
-				index += 1000;
-				kapp->processEvents();
-			}
-		} else
+//	if ( ObjNames.size() ) {
+//		if ( ObjNames.size() > 5000) {
+//			int index=0;
+//			while ( index+1000 < ObjNames.size() ) {
+//				ui->SearchList->addItems( ObjNames.mid( index, 1000 ) );
+//				index += 1000;
+//				kapp->processEvents();
+//			}
+//		} else
 			ui->SearchList->addItems( ObjNames );
+//	}
 
-		selectFirstItem(); // Automatically highlight first item
-	}
+	//If there's a search string, select the first object.  Otherwise, select a default object
+	//(because the first unfiltered object is some random comet)
+	if ( searchString.isEmpty() ) {
+		QListWidgetItem *defaultItem = ui->SearchList->findItems( i18n("Andromeda Galaxy"), Qt::MatchExactly )[0];
+		ui->SearchList->scrollToItem( defaultItem, QAbstractItemView::PositionAtTop );
+		ui->SearchList->setItemSelected( defaultItem, true );
 
+	} else
+			selectFirstItem(); 
+
 	ui->SearchBox->setFocus();  // set cursor to QLineEdit
 }
 


More information about the Kstars-devel mailing list