[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kstars/unfrozen/kstars/kstars
From:       Jason Harris <kstars () 30doradus ! org>
Date:       2008-07-08 5:18:00
Message-ID: 1215494280.868024.17241.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 829313 by harris:

Committing patch from Prakash to make the Find dialog more flexible.  You can now 
omit spaces when searching for M/NGC/IC objects.  
i.e., "m51" will match to "M 51".

Thanks for the patch, Prakash!

CCMAIL: kstars-devel@kde.org



 M  +10 -11    finddialog.cpp  
 M  +1 -1      finddialog.h  


--- branches/kstars/unfrozen/kstars/kstars/finddialog.cpp #829312:829313
@@ -78,8 +78,7 @@
     listFiltered = false;
 }
 
-FindDialog::~FindDialog() {
-}
+FindDialog::~FindDialog() { }
 
 void FindDialog::init() {
     ui->SearchBox->clear();
@@ -197,13 +196,15 @@
 }
 
 void FindDialog::filterList() {  
-    sortModel->setFilterFixedString( ui->SearchBox->text() );
+	QString SearchText;
+	SearchText = processSearchText();
+    sortModel->setFilterFixedString( SearchText );
     filterByType();
     initSelection();
 
     //Select the first item in the list that begins with the filter string
-    if ( ! ui->SearchBox->text().isEmpty() ) {
-        QStringList mItems = fModel->stringList().filter( QRegExp( \
'^'+ui->SearchBox->text(), Qt::CaseInsensitive ) ); +    if ( !SearchText.isEmpty() ) \
{ +        QStringList mItems = fModel->stringList().filter( QRegExp( '^'+SearchText, \
Qt::CaseInsensitive ) );  mItems.sort();
     
         if ( mItems.size() ) {
@@ -247,8 +248,9 @@
 }
 
 // Process the search box text to replace equivalent names like "m93" with "m 93"
-void FindDialog::processSearchText() {
+QString FindDialog::processSearchText() {
     QRegExp re;
+    QString searchtext = ui->SearchBox->text();
 
     // NOTE: The following function has been DEPRECATED. What should I use instead?
     re.setCaseSensitive( false ); 
@@ -256,30 +258,27 @@
     // 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 +
+    return searchtext;
 }
 
 void FindDialog::slotOk() {
     //If no valid object selected, show a sorry-box.  Otherwise, emit accept()
     if(!listFiltered) {
-        processSearchText();
         filterList();
     }
     if(!selectedObject()) {
-        processSearchText();
         filterList();
     }
     if ( selectedObject() == 0 ) {
--- branches/kstars/unfrozen/kstars/kstars/finddialog.h #829312:829313
@@ -112,7 +112,7 @@
      *
      * This could include replacing text like "m93" with "m 93"
      */
-    void processSearchText();
+     QString processSearchText();
 
     /**
      *@short pre-filter the list of objects according to 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic