[Kstars-devel] KDE/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Sun Jan 29 06:25:58 CET 2006
SVN commit 503432 by harris:
More Find dialog fixes. Don't add stars named "star". Make it seem
like the list of names loads quickly. Use QRegExp to filter the list by
name.
CCMAIL: kstars-devel at kde.org
M +17 -12 finddialog.cpp
M +3 -3 skycomponents/starcomponent.cpp
--- trunk/KDE/kdeedu/kstars/kstars/finddialog.cpp #503431:503432
@@ -79,24 +79,29 @@
ui->SearchList->clear();
QStringList ObjNames;
- QString searchString = ui->SearchBox->text().lower();
+ QString searchString = ui->SearchBox->text();
if ( searchString.isEmpty() ) {
ObjNames = p->data()->skyComposite()->objectNames();
} else {
- foreach ( QString name, p->data()->skyComposite()->objectNames() ) {
- if ( name.lower().startsWith( searchString ) ) {
- ObjNames.append( name );
- /* if ( i++ >= 5000 ) { //Every 5000 name insertions,
- kapp->processEvents ( 50 ); //spend 50 msec processing KApplication events
- i = 0;
- }*/
+ QRegExp rx("^"+searchString);
+ rx.setCaseSensitivity( Qt::CaseInsensitive );
+ ObjNames = p->data()->skyComposite()->objectNames().filter(rx);
+ }
+
+ 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 );
+
+ setListItemEnabled(); // Automatically highlight first item
}
- ui->SearchList->addItems( ObjNames );
-
- setListItemEnabled(); // Automatically highlight first item
ui->SearchBox->setFocus(); // set cursor to QLineEdit
}
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #503431:503432
@@ -259,7 +259,7 @@
}
// HEV: look up star name in internationalization filesource
- if ( name.isEmpty() ) name = "star";
+ if ( name.isEmpty() ) name = i18n("star");
name = i18n("star name", name.local8Bit().data());
dms r;
@@ -272,6 +272,6 @@
o->EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
objectList().append(o);
- if ( ! name.isEmpty() ) objectNames().append( name );
- if ( ! gname.isEmpty() && gname != name ) objectNames().append( gname );
+ if ( ! name.isEmpty() && name != i18n("star") ) objectNames().append( name );
+ if ( ! gname.isEmpty() && gname != name ) objectNames().append( o->gname(false) );
}
More information about the Kstars-devel
mailing list