From kstars-devel Wed Jun 04 02:14:05 2008 From: Akarsh Simha Date: Wed, 04 Jun 2008 02:14:05 +0000 To: kstars-devel Subject: [Kstars-devel] KDE/kdeedu/kstars/kstars Message-Id: <1212545645.765180.4253.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kstars-devel&m=121254565830750 SVN commit 816498 by asimha: Make the find dialog more usable, by making it interpret Messier / NGC / IC catalog numbers more intelligently. "M93" is now automatically interpreted as "M 93" if the user typed it in (and not if he selected some other object whose name contains M93 from the list) and so on. Thanks to my friend Prasanna for pointing out this usability issue. CCMAIL: kstars-devel@kde.org M +33 -1 finddialog.cpp M +9 -0 finddialog.h --- trunk/KDE/kdeedu/kstars/kstars/finddialog.cpp #816497:816498 @@ -251,10 +251,42 @@ timer->start( 500 ); } +// Process the search box text to replace equivalent names like "m93" with "m 93" +void FindDialog::processSearchText() { + QRegExp re; + + // NOTE: The following function has been DEPRECATED. What should I use instead? + re.setCaseSensitive( false ); + + // If it is an NGC/IC/M catalog number, as in "M 76" or "NGC 5139", check for absence of the space + re.setPattern("^(m|ngc|ic)\\s*\\d*$"); + if(ui->SearchBox->text().contains(re)) { + QString searchtext = ui->SearchBox->text(); + re.setPattern("\\s*(\\d+)"); + searchtext.replace( re, " \\1" ); + re.setPattern("\\s*$"); + searchtext.replace(re, ""); + re.setPattern("^\\s*"); + searchtext.replace(re, ""); + ui->SearchBox->setText(searchtext); + return; + } + + // TODO after KDE 4.1 release: + // If it is a IAU standard three letter abbreviation for a constellation, then go to that constellation + // Check for genetive names of stars. Example: alp CMa must go to alpha Canis Majoris +} + void FindDialog::slotOk() { //If no valid object selected, show a sorry-box. Otherwise, emit accept() - if(!listFiltered) + if(!listFiltered) { + processSearchText(); filterByName(); + } + if(!selectedObject()) { + processSearchText(); + filterByName(); + } if ( selectedObject() == 0 ) { QString message = i18n( "No object named %1 found.", ui->SearchBox->text() ); KMessageBox::sorry( 0, message, i18n( "Bad object name" ) ); --- trunk/KDE/kdeedu/kstars/kstars/finddialog.h #816497:816498 @@ -107,6 +107,15 @@ void keyPressEvent( QKeyEvent *e ); private: + + /** + * + *@short Do some post processing on the search text to interpret what the user meant + * + * This could include replacing text like "m93" with "m 93" + */ + void processSearchText(); + FindDialogUI* ui; SkyObject* currentitem; QStringListModel *fModel; _______________________________________________ Kstars-devel mailing list Kstars-devel@kde.org https://mail.kde.org/mailman/listinfo/kstars-devel