[kstars/dso_resolver] kstars/dialogs: Add a new button to the Find Dialog, that resolves using internet

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


Git commit 9541af7cfd5fae8a753804ef8341c8c567763bdb by Akarsh Simha.
Committed on 17/08/2016 at 07:00.
Pushed by asimha into branch 'dso_resolver'.

Add a new button to the Find Dialog, that resolves using internet

Without the button: resolution was possible only when the search
filtering did not return any results. Suppose you have "Shk 166"
already in the database, but don't have "Shk 16". Typing just "Shk 16"
will show and select "Shk 166" in the filtered list, with no way of
asking KStars to query Sesame for "Shk 16".

To allow for this, this commit adds a new button that enables internet
search when the list has results, but an exact match has not been
found. If an exact match exists in KStars, the button is grayed out to
prevent multiple copies of the same object from forming. If no search
text is available, once again the button is grayed out. The default
action of hitting Enter is still as before.

The button only appears if the resolution option is selected in the
configuration dialog. The checkbox in the config dialog is still
useful as this can be "messy" for some users who don't want to pollute
their sky map with a bunch of wrong search results.

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

M  +13   -1    kstars/dialogs/finddialog.cpp
M  +5    -0    kstars/dialogs/finddialog.h
M  +7    -0    kstars/dialogs/finddialog.ui

http://commits.kde.org/kstars/9541af7cfd5fae8a753804ef8341c8c567763bdb

diff --git a/kstars/dialogs/finddialog.cpp b/kstars/dialogs/finddialog.cpp
index 84a9d85..0e3fe4c 100644
--- a/kstars/dialogs/finddialog.cpp
+++ b/kstars/dialogs/finddialog.cpp
@@ -77,6 +77,10 @@ FindDialog::FindDialog( QWidget* parent ) :
     buttonBox->addButton(detailB, QDialogButtonBox::ActionRole);
     connect(detailB, SIGNAL(clicked()), this, SLOT(slotDetails()));
 
+    ui->InternetSearchButton->setVisible( Options::resolveNamesOnline() );
+    ui->InternetSearchButton->setEnabled( false );
+    connect( ui->InternetSearchButton, SIGNAL( clicked() ), this, SLOT( slotResolve() ) );
+
     ui->FilterType->setCurrentIndex(0);  // show all types of objects
 
     fModel = new QStringListModel( this );
@@ -226,10 +230,11 @@ void FindDialog::filterByType() {
     }
 }
 
-void FindDialog::filterList() {  
+void FindDialog::filterList() {
     QString SearchText;
     SearchText = processSearchText();
     sortModel->setFilterFixedString( SearchText );
+    ui->InternetSearchButton->setText( i18n( "or search the internet for %1", SearchText ) );
     filterByType();
     initSelection();
 
@@ -250,7 +255,10 @@ void FindDialog::filterList() {
                 okB->setEnabled(true);
             }
         }
+        ui->InternetSearchButton->setEnabled( ! mItems.contains( SearchText ) ); // Disable searching the internet when an exact match for SearchText exists in KStars
     }
+    else
+        ui->InternetSearchButton->setEnabled( false );
 
     listFiltered = true;
 }
@@ -324,6 +332,10 @@ void FindDialog::slotOk() {
     finishProcessing( selObj, Options::resolveNamesOnline() );
 }
 
+void FindDialog::slotResolve() {
+    finishProcessing( 0, true );
+}
+
 void FindDialog::finishProcessing( SkyObject *selObj, bool resolve ) {
     if( ! selObj && resolve ) {
         CatalogEntryData cedata;
diff --git a/kstars/dialogs/finddialog.h b/kstars/dialogs/finddialog.h
index 87cd141..35e60a9 100644
--- a/kstars/dialogs/finddialog.h
+++ b/kstars/dialogs/finddialog.h
@@ -76,6 +76,11 @@ public slots:
      */
     void slotOk();
 
+    /**
+     * @short This slot resolves the object on the internet, ignoring the selection on the list
+     */
+    void slotResolve();
+
 private slots:
     /** Init object list after opening dialog. */
     void init();
diff --git a/kstars/dialogs/finddialog.ui b/kstars/dialogs/finddialog.ui
index 957f691..ea0dbbe 100644
--- a/kstars/dialogs/finddialog.ui
+++ b/kstars/dialogs/finddialog.ui
@@ -64,6 +64,13 @@
    <item>
     <widget class="QListView" name="SearchList"/>
    </item>
+   <item>
+     <widget class="QPushButton" name="InternetSearchButton">
+       <property name="text">
+         <string>or search internet for (nothing)</string>
+       </property>
+     </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>


More information about the kde-doc-english mailing list