[kstars/dso_resolver] kstars/dialogs: Move the processing of acceptance of FindDialog to a separate method

Akarsh Simha akarsh at kde.org
Wed Aug 17 07:05:48 UTC 2016


Git commit 4493f67f381559570c706db1c5b22a838d680381 by Akarsh Simha.
Committed on 17/08/2016 at 06:58.
Pushed by asimha into branch 'dso_resolver'.

Move the processing of acceptance of FindDialog to a separate method

1. Move processing

2. Cosmetics

3. Change comments to reflect current operation

CCMAIL: afedoskin3 at gmail.com, kstars-devel at kde.org

M  +7    -9    kstars/dialogs/finddialog.cpp
M  +9    -3    kstars/dialogs/finddialog.h

http://commits.kde.org/kstars/4493f67f381559570c706db1c5b22a838d680381

diff --git a/kstars/dialogs/finddialog.cpp b/kstars/dialogs/finddialog.cpp
index ce50dd8..84a9d85 100644
--- a/kstars/dialogs/finddialog.cpp
+++ b/kstars/dialogs/finddialog.cpp
@@ -237,11 +237,11 @@ void FindDialog::filterList() {
     if ( !SearchText.isEmpty() ) {
         QStringList mItems = fModel->stringList().filter( QRegExp( '^'+SearchText, Qt::CaseInsensitive ) );
         mItems.sort();
-    
+
         if ( mItems.size() ) {
             QModelIndex qmi = fModel->index( fModel->stringList().indexOf( mItems[0] ) );
             QModelIndex selectItem = sortModel->mapFromSource( qmi );
-    
+
             if ( selectItem.isValid() ) {
                 ui->SearchList->selectionModel()->select( selectItem, QItemSelectionModel::ClearAndSelect );
                 ui->SearchList->scrollTo( selectItem );
@@ -321,11 +321,11 @@ void FindDialog::slotOk() {
         filterList();
     }
     selObj = selectedObject();
-    if( ! selObj && Options::resolveNamesOnline() ) {
-        // ==== FIXME: What follows is buggy testing code : please improve ====
-        // This code is expected to cause crashes / memory leaks
-        // because we don't commit the DSO data to the database, or
-        // any CatalogComponent.
+    finishProcessing( selObj, Options::resolveNamesOnline() );
+}
+
+void FindDialog::finishProcessing( SkyObject *selObj, bool resolve ) {
+    if( ! selObj && resolve ) {
         CatalogEntryData cedata;
         cedata = NameResolver::resolveName( processSearchText() );
         DeepSkyObject *dso = 0;
@@ -335,7 +335,6 @@ void FindDialog::slotOk() {
                 qDebug() << dso->ra0().toHMSString() << ";" << dso->dec0().toDMSString();
             selObj = dso;
         }
-        // ==== END buggy testing code ====
     }
     m_targetObject = selObj;
     if ( selObj == 0 ) {
@@ -345,7 +344,6 @@ void FindDialog::slotOk() {
         accept();
     }
 }
-
 void FindDialog::keyPressEvent( QKeyEvent *e ) {
     switch( e->key() ) {
     case Qt::Key_Escape :
diff --git a/kstars/dialogs/finddialog.h b/kstars/dialogs/finddialog.h
index fb38a2b..87cd141 100644
--- a/kstars/dialogs/finddialog.h
+++ b/kstars/dialogs/finddialog.h
@@ -69,9 +69,10 @@ public slots:
 
     //FIXME: Still valid for QDialog?  i.e., does QDialog have a slotOk() ?
     /**
-     *Overloading the Standard QDialogBase slotOk() to show a "sorry" message
-     *box if no object is selected when the user presses Ok.  The window is
-     *not closed in this case.
+     *Overloading the Standard QDialogBase slotOk() to show a "sorry"
+     *message box if no object is selected and internet resolution was
+     *disabled/failed when the user presses Ok.  The window is not
+     *closed in this case.
      */
     void slotOk();
 
@@ -104,6 +105,11 @@ private:
      */
      QString processSearchText();
 
+     /**
+      * @short Finishes the processing towards closing the dialog initiated by slotOk() or slotResolve()
+      */
+     void finishProcessing( SkyObject *selObj = 0, bool resolve = true );
+
     /** @short pre-filter the list of objects according to the
      * selected object type.
      */



More information about the Kstars-devel mailing list