summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-05-19 11:28:57 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-05-20 04:08:42 (GMT)
commitb7f66ee4301b95898f5965c0542d9d0eae45bedd (patch)
treed261c545a7e95ffed2838426e70e39a9d2913fba
parentc086b6ceb9b715b415010f921b36ee6e6d8942f2 (diff)
Experimental testing: using Name Resolver in Find Dialog
Improvements needed (which is why this is not the end of it): 1. Enable the resolver machinery using a flag in the FindDialog constructor. 2. Find Dialog should show a phantom entry (eg: "Search the internet") to present users that option. 3. We must commit the newly created DeepSkyObject gracefully into some SkyComponent so that it appears in objectNearest() searches and other such places. 4. Allow commiting the newly created object into the SQLite Database.
-rw-r--r--kstars/dialogs/finddialog.cpp20
-rw-r--r--kstars/dialogs/finddialog.h12
-rw-r--r--kstars/ekos/scheduler.cpp2
-rw-r--r--kstars/kstarsactions.cpp2
-rw-r--r--kstars/oal/execute.cpp2
-rw-r--r--kstars/printing/pwizfovsh.cpp2
-rw-r--r--kstars/printing/pwizobjectselection.cpp2
-rw-r--r--kstars/tools/altvstime.cpp2
-rw-r--r--kstars/tools/conjunctions.cpp4
-rw-r--r--kstars/tools/modcalcaltaz.cpp2
-rw-r--r--kstars/tools/modcalcangdist.cpp2
-rw-r--r--kstars/tools/modcalcapcoord.cpp2
-rw-r--r--kstars/tools/modcalceclipticcoords.cpp2
-rw-r--r--kstars/tools/modcalcgalcoord.cpp2
-rw-r--r--kstars/tools/modcalcvlsr.cpp2
-rw-r--r--kstars/tools/observinglist.cpp2
-rw-r--r--kstars/tools/scriptbuilder.cpp6
17 files changed, 47 insertions, 21 deletions
diff --git a/kstars/dialogs/finddialog.cpp b/kstars/dialogs/finddialog.cpp
index 6cd0cfa..35083aa 100644
--- a/kstars/dialogs/finddialog.cpp
+++ b/kstars/dialogs/finddialog.cpp
@@ -23,6 +23,7 @@
#include "skyobjects/skyobject.h"
#include "skycomponents/starcomponent.h"
#include "skycomponents/skymapcomposite.h"
+#include "tools/nameresolver.h"
#include <KMessageBox>
@@ -53,7 +54,8 @@ FindDialogUI::FindDialogUI( QWidget *parent ) : QFrame( parent ) {
FindDialog::FindDialog( QWidget* parent ) :
QDialog( parent ),
- timer(0)
+ timer(0),
+ m_targetObject( 0 )
{
ui = new FindDialogUI( this );
@@ -105,6 +107,7 @@ void FindDialog::init() {
filterByType();
sortModel->sort( 0 );
initSelection();
+ m_targetObject = 0;
}
void FindDialog::initSelection() {
@@ -317,6 +320,21 @@ void FindDialog::slotOk() {
filterList();
}
selObj = selectedObject();
+ if( ! selObj ) {
+ // ==== 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.
+ CatalogEntryData cedata;
+ cedata = NameResolver::resolveName( processSearchText() );
+ DeepSkyObject *dso = new DeepSkyObject( cedata );
+ if( ! std::isnan( cedata.ra ) && ! std::isnan( cedata.dec ) ) {
+ qDebug() << dso->ra0().toHMSString() << ";" << dso->dec0().toDMSString();
+ selObj = dso;
+ }
+ // ==== END buggy testing code ====
+ }
+ m_targetObject = selObj;
if ( selObj == 0 ) {
QString message = i18n( "No object named %1 found.", ui->SearchBox->text() );
KMessageBox::sorry( 0, message, i18n( "Bad object name" ) );
diff --git a/kstars/dialogs/finddialog.h b/kstars/dialogs/finddialog.h
index 1a3f488..fb38a2b 100644
--- a/kstars/dialogs/finddialog.h
+++ b/kstars/dialogs/finddialog.h
@@ -54,8 +54,12 @@ public:
/** Destructor */
virtual ~FindDialog();
- /** @return the currently-selected item from the listbox of named objects */
- SkyObject* selectedObject() const;
+ /**
+ * @return the target object (need not be the same as currently selected object!)
+ *
+ * @note Avoid using selectedObject()
+ */
+ inline SkyObject *targetObject() { return m_targetObject; }
public slots:
/**When Text is entered in the QLineEdit, filter the List of objects
@@ -90,6 +94,9 @@ protected:
*/
void keyPressEvent( QKeyEvent *e );
+ /** @return the currently-selected item from the listbox of named objects */
+ SkyObject* selectedObject() const;
+
private:
/** @short Do some post processing on the search text to interpret what the user meant
@@ -108,6 +115,7 @@ private:
QTimer* timer;
bool listFiltered;
QPushButton *okB;
+ SkyObject *m_targetObject;
};
#endif
diff --git a/kstars/ekos/scheduler.cpp b/kstars/ekos/scheduler.cpp
index ec087ae..3e957d3 100644
--- a/kstars/ekos/scheduler.cpp
+++ b/kstars/ekos/scheduler.cpp
@@ -258,7 +258,7 @@ void Scheduler::selectObject()
QPointer<FindDialog> fd = new FindDialog( this );
if ( fd->exec() == QDialog::Accepted )
{
- SkyObject *object = fd->selectedObject();
+ SkyObject *object = fd->targetObject();
addObject(object);
}
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index d47d20e..c30db0d 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -767,7 +767,7 @@ void KStars::slotFind() {
if ( !m_FindDialog ) qWarning() << i18n( "KStars::slotFind() - Not enough memory for dialog" ) ;
SkyObject *targetObject;
- if ( m_FindDialog->exec() == QDialog::Accepted && ( targetObject = m_FindDialog->selectedObject() ) ) {
+ if ( m_FindDialog->exec() == QDialog::Accepted && ( targetObject = m_FindDialog->targetObject() ) ) {
map()->setClickedObject( targetObject );
map()->setClickedPoint( map()->clickedObject() );
map()->slotCenter();
diff --git a/kstars/oal/execute.cpp b/kstars/oal/execute.cpp
index fbd1356..ea3058f 100644
--- a/kstars/oal/execute.cpp
+++ b/kstars/oal/execute.cpp
@@ -403,7 +403,7 @@ void Execute::slotShowTargets() {
void Execute::slotAddObject() {
QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
if ( fd->exec() == QDialog::Accepted ) {
- SkyObject *o = fd->selectedObject();
+ SkyObject *o = fd->targetObject();
if( o != 0 ) {
KStarsData::Instance()->observingList()->slotAddObject( o, true );
init();
diff --git a/kstars/printing/pwizfovsh.cpp b/kstars/printing/pwizfovsh.cpp
index bae2a42..4b810ed 100644
--- a/kstars/printing/pwizfovsh.cpp
+++ b/kstars/printing/pwizfovsh.cpp
@@ -48,7 +48,7 @@ void PWizFovShUI::slotSelectFromList()
QPointer<FindDialog> findDlg( new FindDialog( this ) );
if(findDlg->exec() == QDialog::Accepted && findDlg)
{
- SkyObject *obj = findDlg->selectedObject();
+ SkyObject *obj = findDlg->targetObject();
if(obj)
{
setBeginObject(obj);
diff --git a/kstars/printing/pwizobjectselection.cpp b/kstars/printing/pwizobjectselection.cpp
index b8a1439..dcf27bf 100644
--- a/kstars/printing/pwizobjectselection.cpp
+++ b/kstars/printing/pwizobjectselection.cpp
@@ -60,7 +60,7 @@ void PWizObjectSelectionUI::slotSelectFromList()
QPointer<FindDialog> findDlg( new FindDialog( this ) );
if(findDlg->exec() == QDialog::Accepted && findDlg)
{
- SkyObject *obj = findDlg->selectedObject();
+ SkyObject *obj = findDlg->targetObject();
if(obj)
{
setSkyObject(obj);
diff --git a/kstars/tools/altvstime.cpp b/kstars/tools/altvstime.cpp
index df98e3e..d017ec0 100644
--- a/kstars/tools/altvstime.cpp
+++ b/kstars/tools/altvstime.cpp
@@ -336,7 +336,7 @@ void AltVsTime::slotAddSource() {
void AltVsTime::slotBrowseObject() {
QPointer<FindDialog> fd = new FindDialog(this);
if ( fd->exec() == QDialog::Accepted ) {
- SkyObject *o = fd->selectedObject();
+ SkyObject *o = fd->targetObject();
processObject( o );
}
delete fd;
diff --git a/kstars/tools/conjunctions.cpp b/kstars/tools/conjunctions.cpp
index 882b352..85efa94 100644
--- a/kstars/tools/conjunctions.cpp
+++ b/kstars/tools/conjunctions.cpp
@@ -164,9 +164,9 @@ void ConjunctionsTool::slotFindObject() {
QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
if ( fd->exec() == QDialog::Accepted ) {
delete Object1;
- if( !fd->selectedObject() )
+ if( !fd->targetObject() )
return;
- Object1 = fd->selectedObject()->clone();
+ Object1 = fd->targetObject()->clone();
if( Object1 )
Obj1FindButton->setText( Object1->name() );
}
diff --git a/kstars/tools/modcalcaltaz.cpp b/kstars/tools/modcalcaltaz.cpp
index cdfeefd..7e38337 100644
--- a/kstars/tools/modcalcaltaz.cpp
+++ b/kstars/tools/modcalcaltaz.cpp
@@ -87,7 +87,7 @@ void modCalcAltAz::slotObject()
{
FindDialog fd(KStars::Instance());
if ( fd.exec() == QDialog::Accepted ) {
- SkyObject *o = fd.selectedObject();
+ SkyObject *o = fd.targetObject();
RA->showInHours( o->ra() );
Dec->showInDegrees( o->dec() );
slotCompute();
diff --git a/kstars/tools/modcalcangdist.cpp b/kstars/tools/modcalcangdist.cpp
index 8dd46ab..497d9e1 100644
--- a/kstars/tools/modcalcangdist.cpp
+++ b/kstars/tools/modcalcangdist.cpp
@@ -96,7 +96,7 @@ void modCalcAngDist::slotValidatePositions(){
void modCalcAngDist::slotObjectButton() {
QPointer<FindDialog> fd = new FindDialog( this );
if ( fd->exec() == QDialog::Accepted ) {
- SkyObject *o = fd->selectedObject();
+ SkyObject *o = fd->targetObject();
if ( sender()->objectName() == QString("FirstObjectButton") ) {
FirstRA->showInHours( o->ra() );
FirstDec->showInDegrees( o->dec() );
diff --git a/kstars/tools/modcalcapcoord.cpp b/kstars/tools/modcalcapcoord.cpp
index 8be76f9..dae3e0d 100644
--- a/kstars/tools/modcalcapcoord.cpp
+++ b/kstars/tools/modcalcapcoord.cpp
@@ -83,7 +83,7 @@ void modCalcApCoord::slotCompute(){
void modCalcApCoord::slotObject() {
QPointer<FindDialog> fd = new FindDialog( this );
if ( fd->exec() == QDialog::Accepted ) {
- SkyObject *o = fd->selectedObject();
+ SkyObject *o = fd->targetObject();
RACat->showInHours( o->ra0() );
DecCat->showInDegrees( o->dec0() );
EpochCat->setValue( 2000.0 );
diff --git a/kstars/tools/modcalceclipticcoords.cpp b/kstars/tools/modcalceclipticcoords.cpp
index 8f1aa35..b28542a 100644
--- a/kstars/tools/modcalceclipticcoords.cpp
+++ b/kstars/tools/modcalceclipticcoords.cpp
@@ -65,7 +65,7 @@ void modCalcEclCoords::slotNow() {
void modCalcEclCoords::slotObject() {
FindDialog fd(KStars::Instance());
if ( fd.exec() == QDialog::Accepted ) {
- SkyObject *o = fd.selectedObject();
+ SkyObject *o = fd.targetObject();
RA->showInHours( o->ra() );
Dec->showInDegrees( o->dec() );
slotCompute();
diff --git a/kstars/tools/modcalcgalcoord.cpp b/kstars/tools/modcalcgalcoord.cpp
index 8427957..2f5e37f 100644
--- a/kstars/tools/modcalcgalcoord.cpp
+++ b/kstars/tools/modcalcgalcoord.cpp
@@ -58,7 +58,7 @@ void modCalcGalCoord::slotObject()
{
QPointer<FindDialog> fd = new FindDialog( this );
if ( fd->exec() == QDialog::Accepted ) {
- SkyObject *o = fd->selectedObject();
+ SkyObject *o = fd->targetObject();
RA->showInHours( o->ra() );
Dec->showInDegrees( o->dec() );
slotComputeCoords();
diff --git a/kstars/tools/modcalcvlsr.cpp b/kstars/tools/modcalcvlsr.cpp
index 18350a0..98e07a2 100644
--- a/kstars/tools/modcalcvlsr.cpp
+++ b/kstars/tools/modcalcvlsr.cpp
@@ -83,7 +83,7 @@ void modCalcVlsr::slotNow()
void modCalcVlsr::slotFindObject() {
QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
if ( fd->exec() == QDialog::Accepted ) {
- SkyObject *o = fd->selectedObject();
+ SkyObject *o = fd->targetObject();
RA->showInHours( o->ra0() );
Dec->showInDegrees( o->dec0() );
}
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index 787a01c..4b97456 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -680,7 +680,7 @@ void ObservingList::slotAddToSession() {
void ObservingList::slotFind() {
QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
if ( fd->exec() == QDialog::Accepted ) {
- SkyObject *o = fd->selectedObject();
+ SkyObject *o = fd->targetObject();
if( o != 0 ) {
slotAddObject( o, sessionView );
}
diff --git a/kstars/tools/scriptbuilder.cpp b/kstars/tools/scriptbuilder.cpp
index b8fad06..4ed6406 100644
--- a/kstars/tools/scriptbuilder.cpp
+++ b/kstars/tools/scriptbuilder.cpp
@@ -1527,13 +1527,13 @@ void ScriptBuilder::slotFindCity() {
void ScriptBuilder::slotFindObject() {
QPointer<FindDialog> fd = new FindDialog( ks );
- if ( fd->exec() == QDialog::Accepted && fd->selectedObject() ) {
+ if ( fd->exec() == QDialog::Accepted && fd->targetObject() ) {
setUnsavedChanges( true );
if (sender() == argLookToward->FindButton)
- argLookToward->FocusEdit->setEditText( fd->selectedObject()->name() );
+ argLookToward->FocusEdit->setEditText( fd->targetObject()->name() );
else
- argFindObject->NameEdit->setText(fd->selectedObject()->name());
+ argFindObject->NameEdit->setText(fd->targetObject()->name());
}
delete fd;
}