summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-08-17 06:58:32 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-08-17 06:58:32 (GMT)
commit4493f67f381559570c706db1c5b22a838d680381 (patch)
tree769e1bbcc3b1253fc8a465f2a709caa36b8283c9
parent91f4c22e0fe3fd4fc093e218f7ff65502470c15a (diff)
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@gmail.com, kstars-devel@kde.org
-rw-r--r--kstars/dialogs/finddialog.cpp16
-rw-r--r--kstars/dialogs/finddialog.h12
2 files changed, 16 insertions, 12 deletions
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.
*/