summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-08-04 10:50:28 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-08-04 10:50:28 (GMT)
commiteecc521f6e3a37144e2270d0e0be37faa70eaf0e (patch)
tree4a700f4c1e59256b7d108550c06621a1bd2e0cac
parent1ec33812527b7ccc0c5b3bb2026994c362ef389c (diff)
Added search to KStars Lite. In KStars Lite we don't need to call
findObject() after user selects object on "Find Object" page because each object's name is associated with corresponding SkyObject and we slew directly to this object. Started to work on controling sky map using motion sensor.
-rw-r--r--kstars/CMakeLists.txt14
-rw-r--r--kstars/kstarslite.cpp11
-rw-r--r--kstars/kstarslite.h5
-rw-r--r--kstars/kstarslite/dialogs/finddialoglite.cpp287
-rw-r--r--kstars/kstarslite/dialogs/finddialoglite.h95
-rw-r--r--kstars/kstarslite/dialogs/skyobjectlistmodel.cpp63
-rw-r--r--kstars/kstarslite/dialogs/skyobjectlistmodel.h58
-rw-r--r--kstars/kstarslite/qml/CMakeLists.txt3
-rw-r--r--kstars/kstarslite/qml/constants/Constants.qml1
-rw-r--r--kstars/kstarslite/qml/dialogs/FindDialog.qml220
-rw-r--r--kstars/kstarslite/qml/indi/DevicePanel.qml5
-rw-r--r--kstars/kstarslite/qml/indi/INDIControlPanel.qml28
-rw-r--r--kstars/kstarslite/qml/indi/modules/KSINDIText.qml6
-rw-r--r--kstars/kstarslite/qml/indi/modules/KSINDITextField.qml3
-rw-r--r--kstars/kstarslite/qml/indi/modules/KSLed.qml1
-rw-r--r--kstars/kstarslite/qml/indi/modules/MotionControl.qml25
-rw-r--r--kstars/kstarslite/qml/main.qml133
-rw-r--r--kstars/kstarslite/qml/modules/KSPage.qml38
-rw-r--r--kstars/kstarslite/qml/modules/TopMenu.qml2
-rw-r--r--kstars/main.cpp2
-rw-r--r--kstars/projections/projector.cpp4
-rw-r--r--kstars/skycomponents/asteroidscomponent.cpp2
-rw-r--r--kstars/skycomponents/cometscomponent.cpp2
-rw-r--r--kstars/skycomponents/constellationnamescomponent.cpp3
-rw-r--r--kstars/skycomponents/deepskycomponent.cpp11
-rw-r--r--kstars/skycomponents/deepskycomponent.h1
-rw-r--r--kstars/skycomponents/planetmoonscomponent.cpp4
-rw-r--r--kstars/skycomponents/satellitescomponent.cpp2
-rw-r--r--kstars/skycomponents/skycomponent.cpp16
-rw-r--r--kstars/skycomponents/skycomponent.h6
-rw-r--r--kstars/skycomponents/skymapcomposite.cpp115
-rw-r--r--kstars/skycomponents/skymapcomposite.h7
-rw-r--r--kstars/skycomponents/solarsystemcomposite.cpp28
-rw-r--r--kstars/skycomponents/solarsystemcomposite.h5
-rw-r--r--kstars/skycomponents/solarsystemsinglecomponent.cpp9
-rw-r--r--kstars/skycomponents/starcomponent.cpp5
-rw-r--r--kstars/skycomponents/supernovaecomponent.cpp8
-rw-r--r--kstars/skymaplite.cpp71
-rw-r--r--kstars/skymaplite.h23
-rw-r--r--kstars/skymapliteevents.cpp22
-rw-r--r--kstars/skyobjects/skyobject.h2
41 files changed, 1204 insertions, 142 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 26bf6ac..483658e 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -610,6 +610,9 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyobjectlite.cpp
#ImageProvider
kstarslite/imageprovider.cpp
+ #Dialogs
+ kstarslite/dialogs/finddialoglite.cpp
+ kstarslite/dialogs/skyobjectlistmodel.cpp
#RootNode
kstarslite/skyitems/rootnode.cpp
kstarslite/skyitems/skyopacitynode.cpp
@@ -687,6 +690,9 @@ if(BUILD_KSTARS_LITE)
kstarslite/qml/modules/Splash.qml
kstarslite/qml/modules/ContextDrawerMenu.qml
kstarslite/qml/modules/TelescopeControlMenu.qml
+ #Dialogs
+ kstarslite/qml/dialogs/FindDialog.qml
+ #INDI
kstarslite/qml/indi/INDIControlPanel.qml
kstarslite/qml/indi/DevicePanel.qml
kstarslite/qml/indi/ImagePreview.qml
@@ -920,9 +926,12 @@ ecm_add_app_icon(KSTARS_APP_SRCS ICONS
${CMAKE_CURRENT_SOURCE_DIR}/icons/128-apps-kstars.png
)
-if(NOT BUILD_KSTARS_LITE)
qt5_add_resources(KSTARS_APP_SRCS data/kstars.qrc)
+add_executable(kstars ${KSTARS_APP_SRCS})
+target_link_libraries(kstars KStarsLib)
+
+if(NOT BUILD_KSTARS_LITE)
install(TARGETS kstars ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
@@ -930,6 +939,3 @@ install(PROGRAMS org.kde.kstars.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES kstars.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES kstars.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})
endif(NOT BUILD_KSTARS_LITE)
-
-add_executable(kstars ${KSTARS_APP_SRCS})
-target_link_libraries(kstars KStarsLib)
diff --git a/kstars/kstarslite.cpp b/kstars/kstarslite.cpp
index 3f037a3..a834010 100644
--- a/kstars/kstarslite.cpp
+++ b/kstars/kstarslite.cpp
@@ -23,9 +23,13 @@
#include <QSurfaceFormat>
#include "indi/clientmanagerlite.h"
#include "kstarslite/imageprovider.h"
+#include "klocalizedcontext.h"
#include "kspaths.h"
+//Dialog
+#include "kstarslite/dialogs/finddialoglite.h"
+
#include "Options.h"
#include "ksutils.h"
@@ -57,6 +61,11 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
m_Engine.rootContext()->setContextProperty("KStarsLite", this);
m_Engine.rootContext()->setContextProperty("KStarsData", m_KStarsData);
m_Engine.rootContext()->setContextProperty("Options", Options::self());
+ m_Engine.rootContext()->setContextObject(new KLocalizedContext(this));
+
+ //Dialogs
+ m_findDialogLite = new FindDialogLite;
+ m_Engine.rootContext()->setContextProperty("FindDialogLite", m_findDialogLite);
//Set Geographic Location from Options
m_KStarsData->setLocationFromOptions();
@@ -68,7 +77,7 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
m_Engine.rootContext()->setContextProperty("SkyMapLite", m_SkyMapLite);
m_imgProvider = new ImageProvider;
m_Engine.addImageProvider(QLatin1String("images"), m_imgProvider);
- //qmlRegisterType<SkyPoint>("skymaplite",1,0,"SkyMapLite");
+ //qmlRegisterType<SkyPoint>("skymaplite",1,0,"SkyMapLite");
#ifdef Q_OS_ANDROID
QString main = KSPaths::locate(QStandardPaths::AppDataLocation, "kstarslite/qml/main.qml");
diff --git a/kstars/kstarslite.h b/kstars/kstarslite.h
index 17e393f..e441340 100644
--- a/kstars/kstarslite.h
+++ b/kstars/kstarslite.h
@@ -29,6 +29,8 @@ class SkyPoint;
class GeoLocation;
class ImageProvider;
+class FindDialogLite;
+
#ifdef INDI_FOUND
class ClientManagerLite;
#endif
@@ -140,6 +142,9 @@ private:
KStarsData *m_KStarsData;
ImageProvider *m_imgProvider;
+ //Dialogs
+ FindDialogLite *m_findDialogLite;
+
#ifdef INDI_FOUND
ClientManagerLite *m_clientManager;
#endif
diff --git a/kstars/kstarslite/dialogs/finddialoglite.cpp b/kstars/kstarslite/dialogs/finddialoglite.cpp
new file mode 100644
index 0000000..adc467b
--- /dev/null
+++ b/kstars/kstarslite/dialogs/finddialoglite.cpp
@@ -0,0 +1,287 @@
+/***************************************************************************
+ finddialoglite.cpp - K Desktop Planetarium
+ -------------------
+ begin : Wed Jul 29 2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "finddialoglite.h"
+
+#include "kstarsdata.h"
+#include "Options.h"
+#include "skyobjects/skyobject.h"
+#include "skycomponents/starcomponent.h"
+#include "skycomponents/skymapcomposite.h"
+#include "skymaplite.h"
+
+#include "solarsystemcomposite.h"
+
+#include <QSortFilterProxyModel>
+#include "skyobjectlistmodel.h"
+#include <QTimer>
+#include <QQmlContext>
+
+FindDialogLite::FindDialogLite( ) :
+ timer(0)
+{
+ m_filterModel.append( i18n ("Any") );
+ m_filterModel.append( i18n ("Stars") );
+ m_filterModel.append( i18n ("Solar System") );
+ m_filterModel.append( i18n ("Open Clusters") );
+ m_filterModel.append( i18n ("Globular Clusters") );
+ m_filterModel.append( i18n ("Gaseous Nebulae") );
+ m_filterModel.append( i18n ("Planetary Nebulae") );
+ m_filterModel.append( i18n ("Galaxies") );
+ m_filterModel.append( i18n ("Comets") );
+ m_filterModel.append( i18n ("Asteroids") );
+ m_filterModel.append( i18n ("Constellations") );
+ m_filterModel.append( i18n ("Supernovae") );
+ m_filterModel.append( i18n ("Satellites") );
+ emit filterModelChanged();
+
+ fModel = new SkyObjectListModel( this );
+ m_sortModel = new QSortFilterProxyModel(this);
+ m_sortModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
+ m_sortModel->setSourceModel( fModel );
+ m_sortModel->setSortRole(SkyObjectListModel::NameRole);
+ m_sortModel->setFilterRole(SkyObjectListModel::NameRole);
+ m_sortModel->setDynamicSortFilter(true);
+ KStarsLite::Instance()->qmlEngine()->rootContext()->setContextProperty("SortModel", m_sortModel);
+ m_sortModel->sort( 0 );
+
+ listFiltered = false;
+}
+
+FindDialogLite::~FindDialogLite() { }
+
+/*void FindDialogLite::initSelection() {
+ if ( m_sortModel->rowCount() <= 0 )
+ {
+ return;
+ }
+
+ //if ( ui->SearchBox->text().isEmpty() ) {
+ //Pre-select the first item
+ QModelIndex selectItem = m_sortModel->index( 0, m_sortModel->filterKeyColumn(), QModelIndex() );
+ switch ( 0) {//ui->FilterType->currentIndex() ) {
+ case 0: //All objects, choose Andromeda galaxy
+ {
+ QModelIndex qmi = fModel->index( fModel->stringList().indexOf( i18n("Andromeda Galaxy") ) );
+ selectItem = m_sortModel->mapFromSource( qmi );
+ break;
+ }
+ case 1: //Stars, choose Aldebaran
+ {
+ QModelIndex qmi = fModel->index( fModel->stringList().indexOf( i18n("Aldebaran") ) );
+ selectItem = m_sortModel->mapFromSource( qmi );
+ break;
+ }
+ case 2: //Solar system or Asteroids, choose Aaltje
+ case 9:
+ {
+ QModelIndex qmi = fModel->index( fModel->stringList().indexOf( i18n("Aaltje") ) );
+ selectItem = m_sortModel->mapFromSource( qmi );
+ break;
+ }
+ case 8: //Comets, choose 'Aarseth-Brewington (1989 W1)'
+ {
+ QModelIndex qmi = fModel->index( fModel->stringList().indexOf( i18n("Aarseth-Brewington (1989 W1)") ) );
+ selectItem = m_sortModel->mapFromSource( qmi );
+ break;
+ }
+
+ }
+ //listFiltered = true;
+}*/
+
+void FindDialogLite::filterByType(uint typeIndex) {
+ KStarsData *data = KStarsData::Instance();
+
+ switch ( typeIndex ) {
+ case 0: // All object types
+ {
+ QVector<QPair<QString, const SkyObject *>> allObjects;
+ foreach( int type, data->skyComposite()->objectLists().keys() ) {
+ allObjects.append(data->skyComposite()->objectLists(SkyObject::TYPE(type)));
+ }
+ fModel->setSkyObjectsList( allObjects );
+ break;
+ }
+ case 1: //Stars
+ {
+ QVector<QPair<QString, const SkyObject *>> starObjects;
+ starObjects.append(data->skyComposite()->objectLists(SkyObject::STAR));
+ starObjects.append(data->skyComposite()->objectLists(SkyObject::CATALOG_STAR));
+ fModel->setSkyObjectsList( starObjects );
+ break;
+ }
+ case 2: //Solar system
+ {
+ QVector<QPair<QString, const SkyObject *>> ssObjects;
+ ssObjects.append(data->skyComposite()->objectLists(SkyObject::PLANET));
+ ssObjects.append(data->skyComposite()->objectLists(SkyObject::COMET));
+ ssObjects.append(data->skyComposite()->objectLists(SkyObject::ASTEROID));
+ ssObjects.append(data->skyComposite()->objectLists(SkyObject::MOON));
+
+ fModel->setSkyObjectsList(ssObjects);
+ break;
+ }
+ case 3: //Open Clusters
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::OPEN_CLUSTER ) );
+ break;
+ case 4: //Globular Clusters
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::GLOBULAR_CLUSTER ) );
+ break;
+ case 5: //Gaseous nebulae
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::GASEOUS_NEBULA ) );
+ break;
+ case 6: //Planetary nebula
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::PLANETARY_NEBULA ) );
+ break;
+ case 7: //Galaxies
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::GALAXY ) );
+ break;
+ case 8: //Comets
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::COMET ) );
+ break;
+ case 9: //Asteroids
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::ASTEROID ) );
+ break;
+ case 10: //Constellations
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::CONSTELLATION ) );
+ break;
+ case 11: //Supernovae
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::SUPERNOVA ) );
+ break;
+ case 12: //Satellites
+ fModel->setSkyObjectsList( data->skyComposite()->objectLists( SkyObject::SATELLITE ) );
+ break;
+ }
+
+ qDebug() << data->skyComposite()->objectLists( SkyObject::SUPERNOVA ) ;
+}
+
+void FindDialogLite::filterList(QString searchQuery) {
+ QString SearchText = processSearchText(searchQuery);
+ m_sortModel->setFilterFixedString( SearchText );
+ //filterByType();
+ //initSelection();
+
+ //Select the first item in the list that begins with the filter string
+ /*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 = m_sortModel->mapFromSource( qmi );
+ }
+ }*/
+
+ listFiltered = true;
+}
+
+void FindDialogLite::selectObject(int index) {
+ QVariant sObj = m_sortModel->data(m_sortModel->index(index, 0), SkyObjectListModel::SkyObjectRole);
+ SkyObject *skyObj = (SkyObject *) sObj.value<void *>();
+ SkyMapLite::Instance()->slotOpenObject(skyObj);
+}
+
+void FindDialogLite::enqueueSearch() {
+ /*listFiltered = false;
+ if ( timer ) {
+ timer->stop();
+ } else {
+ timer = new QTimer( this );
+ timer->setSingleShot( true );
+ connect( timer, SIGNAL( timeout() ), this, SLOT( filterList() ) );
+ }
+ timer->start( 500 );*/
+}
+
+// Process the search box text to replace equivalent names like "m93" with "m 93"
+QString FindDialogLite::processSearchText(QString text) {
+ QRegExp re;
+ QString searchtext = text;
+
+ re.setCaseSensitivity( Qt::CaseInsensitive );
+
+ // 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(text.contains(re)) {
+ re.setPattern("\\s*(\\d+)");
+ searchtext.replace( re, " \\1" );
+ re.setPattern("\\s*$");
+ searchtext.remove( re );
+ re.setPattern("^\\s*");
+ searchtext.remove( re );
+ }
+
+ // 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 FindDialogLite::slotOk() {
+ /*//If no valid object selected, show a sorry-box. Otherwise, emit accept()
+ SkyObject *selObj;
+ if(!listFiltered) {
+ filterList();
+ }
+ selObj = selectedObject();
+ if ( selObj == 0 ) {
+ QString message = i18n( "No object named %1 found.", ui->SearchBox->text() );
+ //KMessageBox::sorry( 0, message, i18n( "Bad object name" ) );
+ } else {
+ accept();
+ }*/
+}
+
+/*void FindDialogLite::keyPressEvent( QKeyEvent *e ) {
+ switch( e->key() ) {
+ case Qt::Key_Escape :
+ reject();
+ break;
+ case Qt::Key_Up :
+ {
+ int currentRow = ui->SearchList->currentIndex().row();
+ if ( currentRow > 0 ) {
+ QModelIndex selectItem = m_sortModel->index( currentRow-1, m_sortModel->filterKeyColumn(), QModelIndex() );
+ ui->SearchList->selectionModel()->setCurrentIndex( selectItem, QItemSelectionModel::SelectCurrent );
+ }
+ break;
+ }
+ case Qt::Key_Down :
+ {
+ int currentRow = ui->SearchList->currentIndex().row();
+ if ( currentRow < m_sortModel->rowCount()-1 ) {
+ QModelIndex selectItem = m_sortModel->index( currentRow+1, m_sortModel->filterKeyColumn(), QModelIndex() );
+ ui->SearchList->selectionModel()->setCurrentIndex( selectItem, QItemSelectionModel::SelectCurrent );
+ }
+ break;
+ }
+ }
+}*/
+
+void FindDialogLite::slotDetails()
+{
+ /*if ( selectedObject() ) {
+ QPointer<DetailDialog> dd = new DetailDialog( selectedObject(), KStarsData::Instance()->ut(), KStarsData::Instance()->geo(), KStars::Instance());
+ dd->exec();
+ delete dd;
+ }*/
+
+}
+
+
diff --git a/kstars/kstarslite/dialogs/finddialoglite.h b/kstars/kstarslite/dialogs/finddialoglite.h
new file mode 100644
index 0000000..9b0a215
--- /dev/null
+++ b/kstars/kstarslite/dialogs/finddialoglite.h
@@ -0,0 +1,95 @@
+/***************************************************************************
+ finddialoglite.h - K Desktop Planetarium
+ -------------------
+ begin : Wed Jul 29 2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef FINDDIALOGLITE_H_
+#define FINDDIALOGLITE_H_
+
+#include <QKeyEvent>
+#include <QDialog>
+
+#include "skyobjects/skyobject.h"
+
+class QTimer;
+class QStringListModel;
+class QSortFilterProxyModel;
+class SkyObjectListModel;
+
+/** @class FindDialogLite
+ * A backend of dialog decleared in QML.
+ *
+ * @short Backend for Find Object Dialog in QML
+ * @author Artem Fedoskin, Jason Harris
+ * @version 1.0
+ */
+class FindDialogLite : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QStringList filterModel READ getFilterModel NOTIFY filterModelChanged)
+public:
+ /**Constructor. Creates all widgets and packs them in QLayouts. Connects
+ * Signals and Slots. Runs initObjectList().
+ */
+ explicit FindDialogLite();
+
+ /** Destructor */
+ virtual ~FindDialogLite();
+
+ Q_INVOKABLE void selectObject(int index);
+
+ QStringList getFilterModel() { return m_filterModel; }
+
+ /** @short pre-filter the list of objects according to the
+ * selected object type.
+ */
+ Q_INVOKABLE void filterByType(uint typeIndex);
+signals:
+ void filterModelChanged();
+
+public slots:
+ /**When Text is entered in the QLineEdit, filter the List of objects
+ * so that only objects which start with the filter text are shown.
+ */
+ Q_INVOKABLE void filterList(QString searchQuery);
+
+ //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.
+ */
+ void slotOk();
+
+private slots:
+ /** Set the selected item to the first item in the list */
+ //void initSelection();
+
+ void enqueueSearch();
+
+ void slotDetails();
+private:
+
+ /** @short Do some post processing on the search text to interpret what the user meant
+ * This could include replacing text like "m93" with "m 93"
+ */
+ QString processSearchText(QString text);
+
+ QStringList m_filterModel;
+ SkyObjectListModel *fModel;
+ QSortFilterProxyModel* m_sortModel;
+ QTimer* timer;
+ bool listFiltered;
+};
+
+#endif
diff --git a/kstars/kstarslite/dialogs/skyobjectlistmodel.cpp b/kstars/kstarslite/dialogs/skyobjectlistmodel.cpp
new file mode 100644
index 0000000..7873ee9
--- /dev/null
+++ b/kstars/kstarslite/dialogs/skyobjectlistmodel.cpp
@@ -0,0 +1,63 @@
+/***************************************************************************
+ skyobjectlistmodel.cpp - K Desktop Planetarium
+ -------------------
+ begin : Wed Jul 29 2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "skyobjectlistmodel.h"
+#include "skyobject.h"
+
+SkyObjectListModel::SkyObjectListModel(QObject *parent)
+ :QAbstractListModel(parent)
+{
+
+}
+
+QHash<int, QByteArray> SkyObjectListModel::roleNames() const {
+ QHash<int, QByteArray> roles;
+ roles[NameRole] = "name";
+ roles[SkyObjectRole] = "skyobject";
+ return roles;
+}
+
+QVariant SkyObjectListModel::data(const QModelIndex &index, int role) const {
+ if(!index.isValid()) {
+ return QVariant();
+ }
+ if(role == NameRole) {
+ return QVariant(skyObjects[index.row()].first);
+ } else if(role == SkyObjectRole) {
+ return qVariantFromValue((void *) skyObjects[index.row()].second);
+ }
+ return QVariant();
+}
+
+
+
+void SkyObjectListModel::setSkyObjectsList(QVector<QPair<QString, const SkyObject *>> sObjects) {
+ emit beginResetModel();
+ skyObjects = sObjects;
+ /*foreach(SkyObject *s, sObjects) {
+ QString name = s->name();
+ if ( ! name.isEmpty() ) {
+ skyObjects.append(QPair<QString, SkyObject *>(name, s));
+ }
+
+ QString longname = s->longname();
+ if ( ! longname.isEmpty() && longname != name) {
+ skyObjects.append(QPair<QString, SkyObject *>(longname, s));
+ }
+ }*/
+ emit endResetModel();
+}
+
diff --git a/kstars/kstarslite/dialogs/skyobjectlistmodel.h b/kstars/kstarslite/dialogs/skyobjectlistmodel.h
new file mode 100644
index 0000000..4dfde2f
--- /dev/null
+++ b/kstars/kstarslite/dialogs/skyobjectlistmodel.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ skyobjectlistmodel.h - K Desktop Planetarium
+ -------------------
+ begin : Wed Jul 29 2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SKYOBJECTLISTMODEL_H_
+#define SKYOBJECTLISTMODEL_H_
+
+#include <QAbstractListModel>
+#include <QDebug>
+
+class SkyObject;
+
+/** @class FindDialogLite
+ * A backend of dialog decleared in QML.
+ *
+ * @short Backend for Find Object Dialog in QML
+ * @author Artem Fedoskin, Jason Harris
+ * @version 1.0
+ */
+class SkyObjectListModel : public QAbstractListModel {
+ Q_OBJECT
+public:
+ enum DemoRoles {
+ NameRole = Qt::UserRole + 1,
+ SkyObjectRole
+ };
+
+ explicit SkyObjectListModel(QObject *parent = 0);
+
+ virtual int rowCount(const QModelIndex&) const { return skyObjects.size(); }
+ virtual QVariant data(const QModelIndex &index, int role) const;
+
+ virtual QHash<int, QByteArray> roleNames() const;
+
+ /*virtual bool removeRows(int row, int count, const QModelIndex &parent) {
+ qDebug() << "TEST";
+ return false;
+ }*/
+
+ void setSkyObjectsList(QVector<QPair<QString, const SkyObject *>> sObjects);
+
+private:
+ QVector<QPair<QString, const SkyObject *>> skyObjects;
+};
+
+#endif
diff --git a/kstars/kstarslite/qml/CMakeLists.txt b/kstars/kstarslite/qml/CMakeLists.txt
index ca51d9c..d65e014 100644
--- a/kstars/kstarslite/qml/CMakeLists.txt
+++ b/kstars/kstarslite/qml/CMakeLists.txt
@@ -15,6 +15,9 @@ install( FILES modules/BottomMenu.qml
modules/TelescopeControlMenu.qml
DESTINATION ${KDE_INSTALL_DATADIR}/kstars/kstarslite/qml/modules )
+install( FILES dialogs/FindDialog.qml
+ DESTINATION ${KDE_INSTALL_DATADIR}/kstars/kstarslite/qml/dialogs )
+
install( FILES modules/helpers/TopMenuButton.qml
DESTINATION ${KDE_INSTALL_DATADIR}/kstars/kstarslite/qml/modules/helpers )
diff --git a/kstars/kstarslite/qml/constants/Constants.qml b/kstars/kstarslite/qml/constants/Constants.qml
index 82d8be9..1317b95 100644
--- a/kstars/kstarslite/qml/constants/Constants.qml
+++ b/kstars/kstarslite/qml/constants/Constants.qml
@@ -28,4 +28,5 @@ QtObject {
}
property string iconpath: "../" + "images/" + density + "/icons/"
property string imagesPath: "images/" + density + "/"
+ property SystemPalette sysPalette: SystemPalette { }
}
diff --git a/kstars/kstarslite/qml/dialogs/FindDialog.qml b/kstars/kstarslite/qml/dialogs/FindDialog.qml
new file mode 100644
index 0000000..c1a8fdc
--- /dev/null
+++ b/kstars/kstarslite/qml/dialogs/FindDialog.qml
@@ -0,0 +1,220 @@
+import QtQuick 2.4
+import QtQuick.Window 2.2
+import QtQuick.Layouts 1.1
+import QtQuick.Dialogs 1.2
+import "../constants" 1.0
+import "../modules"
+import QtQuick.Controls 1.4 as Controls
+import org.kde.kirigami 1.0 as Kirigami
+
+/*AbstractDialog {
+ id: findDialog
+ default property alias data: defaultContentItem.data
+ onVisibilityChanged: if (visible && contentItem) contentItem.forceActiveFocus()
+
+ Rectangle {
+ id: content
+ property real minimumHeight: 320 * num.dp
+ property real minimumWidth: 360 * num.dp
+
+ color: sysPalette.window
+
+ ColumnLayout {
+ id: defaultContentItem
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }*/
+KSPage {
+ contentItem: findColumn
+ title: "Find Object"
+ onVisibleChanged: {
+ if(visible) {
+ typeChoose.currentIndex = 0
+ searchQuery.text = ""
+ }
+ }
+
+ ColumnLayout {
+ id: findColumn
+ spacing: 5 * num.dp
+ anchors{
+ bottom: parent.bottom
+ bottomMargin: 15 * num.dp
+ }
+
+ RowLayout {
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ Controls.Label {
+ text: xi18n("Filter by name: ")
+ color: num.sysPalette.text
+ }
+ Controls.TextField {
+ id: searchQuery
+ Layout.fillWidth: true
+ onTextChanged: {
+ FindDialogLite.filterList(text)
+ }
+ }
+ }
+
+ RowLayout {
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ Controls.Label {
+ text: "Filter by type: "
+ }
+
+ Item {
+ //Spacer
+ Layout.minimumWidth: 30 * num.dp
+ Layout.fillWidth: true
+ }
+
+ Controls.ComboBox {
+ id: typeChoose
+ model: FindDialogLite.filterModel
+ Layout.fillWidth: true
+
+ //Init list with objects when they are loaded
+ Connections {
+ target: mainWindow
+ onLoadedChanged: {
+ if(loaded) {
+ FindDialogLite.filterByType(typeChoose.currentIndex)
+ }
+ }
+ }
+
+ onCurrentIndexChanged: {
+ if(loaded) FindDialogLite.filterByType(currentIndex)
+ }
+ }
+ }
+
+ Controls.ScrollView {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ ListView {
+ id: list
+ clip: true
+
+ model: SortModel
+
+ delegate: Rectangle {
+ id: delRect
+ Layout.fillWidth: true
+ width: parent.width
+ height: objName.height + 30 * num.dp
+
+ border {
+ color: "#becad5"
+ width: 1 * num.dp
+ }
+
+ Behavior on color {
+ ColorAnimation { duration: 200 }
+ }
+
+ states: [
+ State {
+ name: "hovered"
+ PropertyChanges {
+ target: delRect
+ color: "#d0e8fa"
+ }
+ PropertyChanges {
+ target: objName
+ color: Kirigami.Theme.viewTextColor
+ }
+ },
+ State {
+ name: "selected"
+ PropertyChanges {
+ target: delRect
+ color: Kirigami.Theme.highlightColor
+ }
+ PropertyChanges {
+ target: objName
+ color: Kirigami.Theme.highlightedTextColor
+ }
+ },
+ State {
+ name: "default"
+ PropertyChanges {
+ target: delRect
+ color: "white"
+ }
+ PropertyChanges {
+ target: objName
+ color: "black"
+ }
+ }
+ ]
+
+ MouseArea {
+ id: delMouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ function hoveredColor() {
+ if(pressed) {
+ delRect.state = "selected"
+ } else {
+ if(containsMouse) {
+ delRect.state = "hovered"
+ } else {
+ delRect.state = "default"
+ }
+ }
+ }
+
+ onContainsMouseChanged: {
+ hoveredColor()
+ }
+
+ onPressedChanged: {
+ hoveredColor()
+ }
+
+ onClicked: {
+ initPage.showPage()
+ FindDialogLite.selectObject(model.index)
+ }
+ }
+
+ Text {
+ id: objName
+ text: model.name
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ leftMargin: 20 * num.dp
+ }
+ Behavior on color {
+ ColorAnimation { duration: 200 }
+ }
+ }
+ }
+ }
+ }
+
+ Controls.Button {
+ text: "Cancel"
+ onClicked: {
+ goBack()
+ }
+
+ anchors {
+ bottom: parent.bottom
+ right: parent.right
+ }
+ }
+ }
+}
+
diff --git a/kstars/kstarslite/qml/indi/DevicePanel.qml b/kstars/kstarslite/qml/indi/DevicePanel.qml
index ffdac30..f0e3163 100644
--- a/kstars/kstarslite/qml/indi/DevicePanel.qml
+++ b/kstars/kstarslite/qml/indi/DevicePanel.qml
@@ -8,7 +8,10 @@ import org.kde.kirigami 1.0 as Kirigami
Item {
id: devicesPanel
- anchors.fill: parent
+ anchors {
+ fill: parent
+ margins: 0
+ }
function showPage(backtoInit) {
devicesPage.showPage(backtoInit)
}
diff --git a/kstars/kstarslite/qml/indi/INDIControlPanel.qml b/kstars/kstarslite/qml/indi/INDIControlPanel.qml
index a5b46be..c34070d 100644
--- a/kstars/kstarslite/qml/indi/INDIControlPanel.qml
+++ b/kstars/kstarslite/qml/indi/INDIControlPanel.qml
@@ -43,15 +43,6 @@ KSPage {
id: cPanelColumn
spacing: 5 * num.dp
- anchors {
- top: parent.top
- left: parent.left
- right: parent.right
- topMargin: 15 * num.dp
- leftMargin: 25 * num.dp
- rightMargin: 25 * num.dp
- }
-
ColumnLayout {
visible: !indiPage.connected
anchors {
@@ -60,7 +51,8 @@ KSPage {
}
Kirigami.Label {
- text: "INDI Host"
+ text: xi18n("INDI Host")
+ color: num.sysPalette.text
}
RowLayout {
@@ -71,7 +63,7 @@ KSPage {
Controls.TextField {
id:ipHost
- placeholderText: "IP"
+ placeholderText: xi18n("IP")
Layout.alignment: Qt.AlignHCenter
implicitWidth: parent.width*0.8
text: ClientManagerLite.lastUsedServer()
@@ -79,7 +71,7 @@ KSPage {
Controls.TextField {
id:portHost
- placeholderText: "Port"
+ placeholderText: xi18n("Port")
Layout.alignment: Qt.AlignHCenter
implicitWidth: parent.width*0.2
text: ClientManagerLite.lastUsedPort()
@@ -90,20 +82,21 @@ KSPage {
Kirigami.Label {
id: connectedTo
visible: indiPage.connected
- text: "Connected to " + ClientManagerLite.connectedHost
+ color: num.sysPalette.text
+ text: xi18n("Connected to ") + ClientManagerLite.connectedHost
}
Controls.Button {
- text: indiPage.connected ? "Disconnect" : "Connect "
+ text: indiPage.connected ? xi18n("Disconnect") : xi18n("Connect ")
onClicked: {
if(!indiPage.connected) {
if(ClientManagerLite.setHost(ipHost.text, parseInt(portHost.text))) {
- showPassiveNotification("Successfully connected to the server")
+ showPassiveNotification(xi18n("Successfully connected to the server"))
ClientManagerLite.setLastUsedServer(ipHost.text)
ClientManagerLite.setLastUsedPort(portHost.text)
} else {
- showPassiveNotification("Couldn't connect to the server")
+ showPassiveNotification(xi18n("Couldn't connect to the server"))
}
} else {
ClientManagerLite.disconnectHost()
@@ -125,7 +118,8 @@ KSPage {
Kirigami.Label {
id: devicesLabel
- text: "Available Devices"
+ text: xi18n("Available Devices")
+ color: num.sysPalette.text
}
ListModel {
diff --git a/kstars/kstarslite/qml/indi/modules/KSINDIText.qml b/kstars/kstarslite/qml/indi/modules/KSINDIText.qml
index 94bc237..3ef0fd2 100644
--- a/kstars/kstarslite/qml/indi/modules/KSINDIText.qml
+++ b/kstars/kstarslite/qml/indi/modules/KSINDIText.qml
@@ -12,12 +12,13 @@ Column {
Kirigami.Label {
text: propLabel
+ color: num.sysPalette.text
}
Rectangle {
id: separator
height: num.dp
- color: "grey"
+ color: num.sysPalette.light
width: parent.width
}
@@ -34,8 +35,9 @@ Column {
} else {
textItem = Qt.createQmlObject('import QtQuick 2.4
import QtQuick.Layouts 1.2
+ import "../../constants" 1.0
Text {
-
+ color: num.sysPalette.text
}', this)
textItem.text = propText
}
diff --git a/kstars/kstarslite/qml/indi/modules/KSINDITextField.qml b/kstars/kstarslite/qml/indi/modules/KSINDITextField.qml
index 92ab3cd..6b854d1 100644
--- a/kstars/kstarslite/qml/indi/modules/KSINDITextField.qml
+++ b/kstars/kstarslite/qml/indi/modules/KSINDITextField.qml
@@ -25,8 +25,9 @@ Flow {
TextField {
id: field
}
+
Button {
- text:"Set"
+ text: xi18n("Set")
onClicked: {
if(isNumber) {
ClientManagerLite.sendNewINDINumber(deviceName, propName, fieldName, field.text)
diff --git a/kstars/kstarslite/qml/indi/modules/KSLed.qml b/kstars/kstarslite/qml/indi/modules/KSLed.qml
index c16e146..a719e49 100644
--- a/kstars/kstarslite/qml/indi/modules/KSLed.qml
+++ b/kstars/kstarslite/qml/indi/modules/KSLed.qml
@@ -49,5 +49,6 @@ Row {
Kirigami.Label {
text: ledRow.label
anchors.verticalCenter: parent.verticalCenter
+ color: num.sysPalette.text
}
}
diff --git a/kstars/kstarslite/qml/indi/modules/MotionControl.qml b/kstars/kstarslite/qml/indi/modules/MotionControl.qml
index e38ddf3..65270bd 100644
--- a/kstars/kstarslite/qml/indi/modules/MotionControl.qml
+++ b/kstars/kstarslite/qml/indi/modules/MotionControl.qml
@@ -61,7 +61,7 @@ ColumnLayout {
}
}
- text: "NW"
+ text: xi18n("NW")
}
Button {
@@ -81,7 +81,7 @@ ColumnLayout {
}
}
- text: "N"
+ text: xi18n("N")
}
Button {
@@ -103,7 +103,7 @@ ColumnLayout {
}
}
- text: "NE"
+ text: xi18n("NE")
}
}
@@ -129,7 +129,7 @@ ColumnLayout {
}
}
- text: "W"
+ text: xi18n("W")
}
Button {
@@ -145,7 +145,7 @@ ColumnLayout {
}
}
- text: "Stop"
+ text: xi18n("Stop")
}
Button {
@@ -165,7 +165,7 @@ ColumnLayout {
}
}
- text: "E"
+ text: xi18n("E")
}
}
@@ -191,7 +191,7 @@ ColumnLayout {
}
}
- text: "SW"
+ text: xi18n("SW")
}
Button {
@@ -200,7 +200,7 @@ ColumnLayout {
activeFocusOnTab: false
- text: "S"
+ text: xi18n("S")
onPressedChanged: {
@@ -233,7 +233,7 @@ ColumnLayout {
}
}
- text: "SE"
+ text: xi18n("SE")
}
}
@@ -263,14 +263,15 @@ ColumnLayout {
}
}
- text: "-"
+ text: xi18n("-")
}
Text {
height: parent.height * 0.15
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
+ color: num.sysPalette.text
- text: "Slewing speed control"
+ text: xi18n("Slewing speed control")
}
Button {
@@ -293,7 +294,7 @@ ColumnLayout {
}
}
- text: "+"
+ text: xi18n("+")
}
}
}
diff --git a/kstars/kstarslite/qml/main.qml b/kstars/kstarslite/qml/main.qml
index fec5b78..58f8bb8 100644
--- a/kstars/kstarslite/qml/main.qml
+++ b/kstars/kstarslite/qml/main.qml
@@ -4,9 +4,11 @@ import QtQuick.Layouts 1.1
import "modules"
import "indi"
import "constants" 1.0
+import "dialogs"
import QtQuick.Controls 1.4 as Controls
import org.kde.kirigami 1.0 as Kirigami
import QtSensors 5.0
+import QtGraphicalEffects 1.0
Kirigami.ApplicationWindow {
id: mainWindow
@@ -27,6 +29,16 @@ Kirigami.ApplicationWindow {
property var telescopes: []
+ //pageStack.currentIndex: initPage
+
+ property Item currentPage: initPage
+
+ controlsVisible: false
+
+ header: Kirigami.ApplicationHeader {
+ visible: false
+ }
+
property bool loaded: false
Splash {
@@ -38,14 +50,6 @@ Kirigami.ApplicationWindow {
}
}
- property Item currentPage: initPage
-
- controlsVisible: false
-
- header: Kirigami.ApplicationHeader {
- visible: false
- }
-
contentItem.anchors.topMargin: 0
wideScreen: true
@@ -62,7 +66,6 @@ Kirigami.ApplicationWindow {
text: "Sky Map"
onTriggered: {
- mainWindow.currentPage = initPage
initPage.showPage(true)
globalDrawer.close()
}
@@ -75,6 +78,14 @@ Kirigami.ApplicationWindow {
indiControlPanel.showPage(true)
globalDrawer.close()
}
+ },
+ Kirigami.Action {
+ text: "Find Object"
+
+ onTriggered: {
+ findDialog.showPage(true)
+ globalDrawer.close()
+ }
}
]
@@ -88,13 +99,66 @@ Kirigami.ApplicationWindow {
maximumValue: 5.75954
minimumValue: 1.18778
value: SkyMapLite.magLim
-
onValueChanged: {
SkyMapLite.magLim = value
}
}
}
+ FindDialog {
+ id: findDialog
+ }
+
+ //Background shadow
+
+ /*function showBgShadow() {
+ shadowBg.state = "visible"
+ }
+
+ function hideBgShadow() {
+ shadowBg.state = "hidden"
+ }
+
+ Item {
+ id: shadowBg
+ state: "hidden"
+ anchors.fill: parent
+ z: bgOrder
+
+ Rectangle {
+ id: shadowRect
+ anchors.fill: parent
+ color: "black"
+ }
+
+ FastBlur {
+ anchors.fill: shadowRect
+ source: shadowRect
+ radius: Units.gridUnit
+ transparentBorder: true
+ }
+
+ states: [
+ State {
+ name: "visible"
+ PropertyChanges {
+ target: shadowBg
+ opacity: 0.3
+ }
+ },
+ State {
+ name: "hidden"
+ PropertyChanges {
+ target: shadowBg
+ opacity: 0
+ }
+ }]
+
+ Behavior on opacity {
+ NumberAnimation { duration: 200 }
+ }
+ }*/
+
contextDrawer: Kirigami.ContextDrawer {
id: contextDrawer
property Item contextMenu
@@ -129,7 +193,7 @@ Kirigami.ApplicationWindow {
KSPage {
id: initPage
title: "Main Screen"
- visible: loaded
+ visible:true
TapSensor {
onReadingChanged: {
@@ -212,6 +276,15 @@ Kirigami.ApplicationWindow {
]
}
+ Splash {
+ z:1
+ anchors.fill:parent
+ onTimeout: {
+ loaded = true
+ mainWindow.controlsVisible = true
+ }
+ }
+
/*content is made Rectangle to allow z-index ordering
(for some reason it doesn't work with plain Item)*/
Item {
@@ -227,28 +300,28 @@ Kirigami.ApplicationWindow {
color: "black"
Rectangle {
- id: tapCircle
- z: 1
- width: 20 * num.dp
- height: width
- color: "grey"
- radius: width*0.5
- opacity: 0
-
- Connections {
- target: SkyMapLite
- onPosClicked: {
+ id: tapCircle
+ z: 1
+ width: 20 * num.dp
+ height: width
+ color: "grey"
+ radius: width*0.5
+ opacity: 0
+
+ Connections {
+ target: SkyMapLite
+ onPosClicked: {
tapCircle.x = pos.x - tapCircle.width * 0.5
tapCircle.y = pos.y - tapCircle.height * 0.5
tapAnimation.start()
- }
- }
-
- SequentialAnimation on opacity {
- id: tapAnimation
- OpacityAnimator { from: 0; to: 0.8; duration: 100 }
- OpacityAnimator { from: 0.8; to: 0; duration: 400 }
- }
+ }
+ }
+
+ SequentialAnimation on opacity {
+ id: tapAnimation
+ OpacityAnimator { from: 0; to: 0.8; duration: 100 }
+ OpacityAnimator { from: 0.8; to: 0; duration: 400 }
+ }
}
/*MouseArea {
diff --git a/kstars/kstarslite/qml/modules/KSPage.qml b/kstars/kstarslite/qml/modules/KSPage.qml
index 173ef7f..ca447e5 100644
--- a/kstars/kstarslite/qml/modules/KSPage.qml
+++ b/kstars/kstarslite/qml/modules/KSPage.qml
@@ -14,17 +14,24 @@ Kirigami.Page {
anchors.fill: parent
visible: false
+ background: Rectangle {
+ color: num.sysPalette.window
+ }
+
+ id: parentPage
+
property Item contentItem: null
property Item prevPage: null
function showPage(backtoInit) {
- if(backtoInit) {
- mainWindow.currentPage.visible = false // Hide current page
+ if(this === initPage) { //Exit if user goes back on initPage
+ prevPage = null
+ } else if(backtoInit) {
prevPage = mainWindow.initPage // Go back to SkyMap
} else {
prevPage = mainWindow.currentPage
}
- prevPage.visible = false
+ mainWindow.currentPage.visible = false // Hide current page
visible = true
mainWindow.currentPage = this
}
@@ -67,7 +74,7 @@ Kirigami.Page {
anchors.leftMargin: 10 * num.dp
Rectangle {
- id: backRect
+ id: goBackRect
radius: width * 0.5
color: "#F0F0F0"
//opacity: 0
@@ -83,11 +90,11 @@ Kirigami.Page {
}
onPressedChanged: {
if(pressed) {
- backRect.state = "pressed"
- console.log(backRect.state)
+ goBackRect.state = "pressed"
+ console.log(goBackRect.state)
} else {
- backRect.state = "released"
- console.log(backRect.state)
+ goBackRect.state = "released"
+ console.log(goBackRect.state)
}
}
}
@@ -95,12 +102,12 @@ Kirigami.Page {
states: [
State {
name: "pressed"
- PropertyChanges { target: backRect; opacity: 0.3 }
+ PropertyChanges { target: goBackRect; opacity: 0.3 }
//PropertyChanges { target: backButton; opacity: 0.6 }
},
State {
name: "released"
- PropertyChanges { target: backRect; opacity: 0 }
+ PropertyChanges { target: goBackRect; opacity: 0 }
//PropertyChanges { target: backButton; opacity: 1 }
}
]
@@ -109,12 +116,12 @@ Kirigami.Page {
Transition {
from: "released"
to: "pressed"
- PropertyAnimation { target: backRect; properties: "opacity"; duration: 100 }
+ PropertyAnimation { target: goBackRect; properties: "opacity"; duration: 100 }
},
Transition {
from: "pressed"
to: "released"
- PropertyAnimation { target: backRect; properties: "opacity"; duration: 150 }
+ PropertyAnimation { target: goBackRect; properties: "opacity"; duration: 150 }
}
]
}
@@ -125,7 +132,7 @@ Kirigami.Page {
source: "images/" + num.density + "/icons/back.png"
sourceSize.height: pageTitle.height + 2 * num.dp
sourceSize.width: pageTitle.height + 2 * num.dp
- anchors.centerIn: backRect
+ anchors.centerIn: goBackRect
}
Text {
@@ -155,8 +162,9 @@ Kirigami.Page {
contentItem.anchors.top = headerRect.bottom
contentItem.anchors.left = contentItem.parent.left
contentItem.anchors.right = contentItem.parent.right
- //contentItem.anchors.leftMargin = 25
- //contentItem.anchors.rightMargin = 25
+ contentItem.anchors.topMargin = 15 * num.dp
+ contentItem.anchors.leftMargin = 25 * num.dp
+ contentItem.anchors.rightMargin = 25 * num.dp
}
}
}
diff --git a/kstars/kstarslite/qml/modules/TopMenu.qml b/kstars/kstarslite/qml/modules/TopMenu.qml
index e28daf7..b4eca2e 100644
--- a/kstars/kstarslite/qml/modules/TopMenu.qml
+++ b/kstars/kstarslite/qml/modules/TopMenu.qml
@@ -89,7 +89,6 @@ ColumnLayout {
MouseArea {
anchors.fill: parent
onClicked: {
- Options.showJupiter = !Options.showJupiter
KStarsLite.fullUpdate()
}
}
@@ -99,7 +98,6 @@ ColumnLayout {
MouseArea {
anchors.fill: parent
onClicked: {
- Options.showSolarSystem = !Options.showSolarSystem
KStarsLite.fullUpdate()
}
}
diff --git a/kstars/main.cpp b/kstars/main.cpp
index d7aeb0c..6481f07 100644
--- a/kstars/main.cpp
+++ b/kstars/main.cpp
@@ -251,7 +251,7 @@ int main(int argc, char *argv[])
Options::setShowStars(true);
Options::setShowDeepSky(true);
- Options::setShowCBounds(true);
+ Options::setShowCBounds(false);
Options::setShowCLines(true);
Options::setShowSolarSystem(true);
Options::setShowEcliptic(true);
diff --git a/kstars/projections/projector.cpp b/kstars/projections/projector.cpp
index 2d45b7a..046eea8 100644
--- a/kstars/projections/projector.cpp
+++ b/kstars/projections/projector.cpp
@@ -207,6 +207,8 @@ bool Projector::checkVisibility( SkyPoint *p ) const
*/ //Here we hope that the point has already been 'synchronized'
if( m_vp.fillGround /*&& m_vp.useAltAz*/ && p->alt().Degrees() < -1.0 ) return false;
+ SkyMapLite *map = SkyMapLite::Instance();
+
if ( m_vp.useAltAz ) {
/** To avoid calculating refraction, we just use the unrefracted
altitude and add a 2-degree 'safety factor' */
@@ -277,7 +279,7 @@ QVector< Vector2f > Projector::groundPoly(SkyPoint* labelpoint, bool *drawLabel)
//daz is 1/2 the width of the sky in degrees
double daz = 90.;
if ( m_vp.useAltAz ) {
- daz = 0.5*m_vp.width*57.3/m_vp.zoomFactor; //center to edge, in degrees
+ //daz = (0.5*m_vp.width*57.3)/m_vp.zoomFactor; //center to edge, in degrees. Why do we need it? It finishes horizon incorrectly - A. Fedoskin(polaris)
if ( type() == Orthographic ) {
daz = daz * 1.4;
}
diff --git a/kstars/skycomponents/asteroidscomponent.cpp b/kstars/skycomponents/asteroidscomponent.cpp
index 31f806d..6404723 100644
--- a/kstars/skycomponents/asteroidscomponent.cpp
+++ b/kstars/skycomponents/asteroidscomponent.cpp
@@ -95,6 +95,7 @@ void AsteroidsComponent::loadData()
// Clear lists
m_ObjectList.clear();
objectNames( SkyObject::ASTEROID ).clear();
+ objectLists( SkyObject::ASTEROID ).clear();
QList< QPair<QString, KSParser::DataTypes> > sequence;
sequence.append(qMakePair(QString("full name"), KSParser::D_QSTRING));
@@ -187,6 +188,7 @@ void AsteroidsComponent::loadData()
m_ObjectList.append(new_asteroid);
// Add name to the list of object names
objectNames(SkyObject::ASTEROID).append(name);
+ objectLists( SkyObject::ASTEROID ).append(QPair<QString, const SkyObject*>(name,new_asteroid));
}
}
diff --git a/kstars/skycomponents/cometscomponent.cpp b/kstars/skycomponents/cometscomponent.cpp
index 93deaf8..4dfff4d 100644
--- a/kstars/skycomponents/cometscomponent.cpp
+++ b/kstars/skycomponents/cometscomponent.cpp
@@ -91,6 +91,7 @@ void CometsComponent::loadData() {
emitProgressText(i18n("Loading comets"));
objectNames(SkyObject::COMET).clear();
+ objectLists(SkyObject::COMET).clear();
QList< QPair<QString, KSParser::DataTypes> > sequence;
sequence.append(qMakePair(QString("full name"), KSParser::D_QSTRING));
@@ -174,6 +175,7 @@ void CometsComponent::loadData() {
// Add *short* name to the list of object names
objectNames( SkyObject::COMET ).append( com->name() );
+ objectLists( SkyObject::COMET ).append(QPair<QString, const SkyObject*>(com->name(),com));
}
}
diff --git a/kstars/skycomponents/constellationnamescomponent.cpp b/kstars/skycomponents/constellationnamescomponent.cpp
index 9fb1528..7ac5a96 100644
--- a/kstars/skycomponents/constellationnamescomponent.cpp
+++ b/kstars/skycomponents/constellationnamescomponent.cpp
@@ -31,7 +31,7 @@
#include "projections/projector.h"
ConstellationNamesComponent::ConstellationNamesComponent(SkyComposite *parent, CultureList* cultures )
- : ListComponent(parent )
+ : ListComponent( parent )
{
uint i = 0;
bool culture = false;
@@ -88,6 +88,7 @@ ConstellationNamesComponent::ConstellationNamesComponent(SkyComposite *parent, C
//Add name to the list of object names
objectNames(SkyObject::CONSTELLATION).append( name );
+ objectLists(SkyObject::CONSTELLATION).append(QPair<QString, const SkyObject*>(name, o));
}
}
}
diff --git a/kstars/skycomponents/deepskycomponent.cpp b/kstars/skycomponents/deepskycomponent.cpp
index cc5405c..1e0af5b 100644
--- a/kstars/skycomponents/deepskycomponent.cpp
+++ b/kstars/skycomponents/deepskycomponent.cpp
@@ -276,7 +276,7 @@ void DeepSkyComponent::loadData()
o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
// Add the name(s) to the nameHash for fast lookup -jbb
- if ( hasName) {
+ if ( hasName ) {
nameHash[ name.toLower() ] = o;
if ( ! longname.isEmpty() ) nameHash[ longname.toLower() ] = o;
if ( ! name2.isEmpty() ) nameHash[ name2.toLower() ] = o;
@@ -308,13 +308,17 @@ void DeepSkyComponent::loadData()
// JM: VERY INEFFICIENT. Disabling for now until we figure out how to deal with dups. QSet?
//if ( ! name.isEmpty() && !objectNames(type).contains(name))
- if ( ! name.isEmpty() )
+ if ( ! name.isEmpty() ) {
objectNames(type).append( name );
+ objectLists(type).append( QPair<QString, SkyObject *>(name, o));
+ }
//Add long name to the list of object names
//if ( ! longname.isEmpty() && longname != name && !objectNames(type).contains(longname))
- if ( ! longname.isEmpty() && longname != name)
+ if ( ! longname.isEmpty() && longname != name) {
objectNames(type).append( longname );
+ objectLists(type).append( QPair<QString, SkyObject *>(longname, o));
+ }
deep_sky_parser.ShowProgress();
}
@@ -531,7 +535,6 @@ void DeepSkyComponent::objectsInArea( QList<SkyObject*>& list, const SkyRegion&
}
}
-
//we multiply each catalog's smallest angular distance by the
//following factors before selecting the final nearest object:
// IC catalog = 0.8
diff --git a/kstars/skycomponents/deepskycomponent.h b/kstars/skycomponents/deepskycomponent.h
index f8ef7d2..d184d78 100644
--- a/kstars/skycomponents/deepskycomponent.h
+++ b/kstars/skycomponents/deepskycomponent.h
@@ -156,6 +156,7 @@ private:
const QString& colorString, bool drawImage = false);
QList<DeepSkyObject*> m_DeepSkyList;
+
QList<DeepSkyObject*> m_MessierList;
QList<DeepSkyObject*> m_NGCList;
QList<DeepSkyObject*> m_ICList;
diff --git a/kstars/skycomponents/planetmoonscomponent.cpp b/kstars/skycomponents/planetmoonscomponent.cpp
index e60a5fc..d69aafd 100644
--- a/kstars/skycomponents/planetmoonscomponent.cpp
+++ b/kstars/skycomponents/planetmoonscomponent.cpp
@@ -58,8 +58,10 @@ PlanetMoonsComponent::PlanetMoonsComponent( SkyComposite *p,
delete pmoons;
pmoons = new JupiterMoons();
int nmoons = pmoons->nMoons();
- for ( int i=0; i<nmoons; ++i )
+ for ( int i=0; i<nmoons; ++i ) {
objectNames(SkyObject::MOON).append( pmoons->name(i) );
+ objectLists(SkyObject::MOON).append( QPair<QString, const SkyObject*>(pmoons->name(i),pmoons->moon(i)) );
+ }
}
PlanetMoonsComponent::~PlanetMoonsComponent()
diff --git a/kstars/skycomponents/satellitescomponent.cpp b/kstars/skycomponents/satellitescomponent.cpp
index efdc60e..bf42f4a 100644
--- a/kstars/skycomponents/satellitescomponent.cpp
+++ b/kstars/skycomponents/satellitescomponent.cpp
@@ -54,6 +54,7 @@ SatellitesComponent::SatellitesComponent( SkyComposite *parent ) :
}
objectNames(SkyObject::SATELLITE).clear();
+ objectLists(SkyObject::SATELLITE).clear();
foreach( SatelliteGroup *group, m_groups )
{
@@ -63,6 +64,7 @@ SatellitesComponent::SatellitesComponent( SkyComposite *parent ) :
if ( sat->selected() && nameHash.contains(sat->name().toLower()) == false)
{
objectNames(SkyObject::SATELLITE).append(sat->name());
+ objectLists(SkyObject::SATELLITE).append(QPair<QString, const SkyObject*>(sat->name(), sat));
nameHash[sat->name().toLower()] = sat;
}
}
diff --git a/kstars/skycomponents/skycomponent.cpp b/kstars/skycomponents/skycomponent.cpp
index 29c6779..db3e9cf 100644
--- a/kstars/skycomponents/skycomponent.cpp
+++ b/kstars/skycomponents/skycomponent.cpp
@@ -55,6 +55,10 @@ QHash<int, QStringList>& SkyComponent::getObjectNames() {
return parent()->objectNames();
}
+QHash<int, QVector<QPair<QString, const SkyObject *>>>& SkyComponent::getObjectLists() {
+ return parent()->objectLists();
+}
+
void SkyComponent::removeFromNames(const SkyObject* obj) {
QStringList& names = getObjectNames()[obj->type()];
int i;
@@ -66,3 +70,15 @@ void SkyComponent::removeFromNames(const SkyObject* obj) {
if ( i >= 0 )
names.removeAt( i );
}
+
+void SkyComponent::removeFromLists(const SkyObject* obj) {
+ QVector<QPair<QString, const SkyObject*>>& names = getObjectLists()[obj->type()];
+ int i;
+ i = names.indexOf( QPair<QString, const SkyObject*>(obj->name(), obj) );
+ if ( i >= 0 )
+ names.removeAt( i );
+
+ i = names.indexOf( QPair<QString, const SkyObject*>(obj->longname(),obj) );
+ if ( i >= 0 )
+ names.removeAt( i );
+}
diff --git a/kstars/skycomponents/skycomponent.h b/kstars/skycomponents/skycomponent.h
index cf84c14..883b916 100644
--- a/kstars/skycomponents/skycomponent.h
+++ b/kstars/skycomponents/skycomponent.h
@@ -209,12 +209,18 @@ public:
inline QStringList& objectNames(int type) { return getObjectNames()[type]; }
+ inline QHash<int, QVector<QPair<QString, const SkyObject *>>>& objectLists() { return getObjectLists(); }
+
+ inline QVector<QPair<QString, const SkyObject *>>& objectLists(int type) { return getObjectLists()[type]; }
+
protected:
void removeFromNames(const SkyObject* obj);
+ void removeFromLists(const SkyObject* obj);
private:
/** */
virtual QHash<int, QStringList>& getObjectNames();
+ virtual QHash<int, QVector<QPair<QString, const SkyObject *>>>& getObjectLists();
// Disallow copying and assignement
SkyComponent(const SkyComponent&);
diff --git a/kstars/skycomponents/skymapcomposite.cpp b/kstars/skycomponents/skymapcomposite.cpp
index 92d46f4..3713a47 100644
--- a/kstars/skycomponents/skymapcomposite.cpp
+++ b/kstars/skycomponents/skymapcomposite.cpp
@@ -66,7 +66,7 @@
#include "typedef.h"
SkyMapComposite::SkyMapComposite(SkyComposite *parent ) :
- SkyComposite(parent), m_reindexNum( J2000 )
+ SkyComposite(parent), m_reindexNum( J2000 )
{
m_skyLabeler = SkyLabeler::Instance();
m_skyMesh = SkyMesh::Create( 3 ); // level 5 mesh = 8192 trixels
@@ -102,14 +102,14 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent ) :
QStringList allcatalogs = Options::showCatalogNames();
for ( int i=0; i < allcatalogs.size(); ++ i ) {
m_CustomCatalogs->addComponent(
- new CatalogComponent( this, allcatalogs.at(i), false, i ), 6
- );
+ new CatalogComponent( this, allcatalogs.at(i), false, i ), 6
+ );
}
addComponent( m_SolarSystem = new SolarSystemComposite( this ), 2);
//addComponent( m_ObservingList = new TargetListComponent( this , 0, QPen(),
- // &Options::obsListSymbol, &Options::obsListText ), 120 );
+ // &Options::obsListSymbol, &Options::obsListText ), 120 );
addComponent( m_StarHopRouteList = new TargetListComponent( this , 0, QPen() ), 130 );
addComponent( m_Satellites = new SatellitesComponent( this ), 7 );
addComponent( m_Supernovae = new SupernovaeComponent( this ), 7 );
@@ -124,7 +124,7 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent ) :
addComponent( m_CBoundLines = new ConstellationBoundaryLines( this ), 80);
m_Cultures = new CultureList();
addComponent( m_CLines = new ConstellationLines( this, m_Cultures ), 85);
- addComponent( m_CNames = new ConstellationNamesComponent( this, m_Cultures ), 90);
+ addComponent( m_CNames = new ConstellationNamesComponent( this, m_Cultures ), 90);
addComponent( m_Equator = new Equator( this ), 95);
addComponent( m_Ecliptic = new Ecliptic( this ), 95);
addComponent( m_Horizon = new HorizonComponent( this ), 100);
@@ -137,8 +137,8 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent ) :
QStringList allcatalogs = Options::showCatalogNames();
for ( int i=0; i < allcatalogs.size(); ++ i ) {
m_CustomCatalogs->addComponent(
- new CatalogComponent( this, allcatalogs.at(i), false, i ), 6
- );
+ new CatalogComponent( this, allcatalogs.at(i), false, i ), 6
+ );
}
addComponent( m_SolarSystem = new SolarSystemComposite( this ), 2);
@@ -159,9 +159,9 @@ SkyMapComposite::~SkyMapComposite()
delete m_skyLabeler; // These are on the heap to avoid header file hell.
delete m_skyMesh;
delete m_Cultures;
- #ifndef KSTARS_LITE
+#ifndef KSTARS_LITE
delete m_Flags;
- #endif
+#endif
}
void SkyMapComposite::update(KSNumbers *num )
@@ -394,12 +394,12 @@ SkyObject* SkyMapComposite::objectNearest( SkyPoint *p, double &maxrad ) {
}
for( int i = 0; i < m_DeepStars.size(); ++i ) {
- rTry = maxrad;
- oTry = m_DeepStars.at( i )->objectNearest( p, rTry );
- if( rTry < rBest ) {
- rBest = rTry;
- oBest = oTry;
- }
+ rTry = maxrad;
+ oTry = m_DeepStars.at( i )->objectNearest( p, rTry );
+ if( rTry < rBest ) {
+ rBest = rTry;
+ oBest = oTry;
+ }
}
rTry = maxrad;
@@ -441,7 +441,7 @@ SkyObject* SkyMapComposite::objectNearest( SkyPoint *p, double &maxrad ) {
}
//if ( oBest && Options::verboseLogging())
- //qDebug() << "OBEST=" << oBest->name() << " - " << oBest->name2();
+ //qDebug() << "OBEST=" << oBest->name() << " - " << oBest->name2();
maxrad = rBest;
return oBest; //will be 0 if no object nearer than maxrad was found
@@ -481,6 +481,10 @@ QHash<int, QStringList>& SkyMapComposite::getObjectNames() {
return m_ObjectNames;
}
+QHash<int, QVector<QPair<QString, const SkyObject*>>>& SkyMapComposite::getObjectLists() {
+ return m_ObjectLists;
+}
+
QList<SkyObject*> SkyMapComposite::findObjectsInArea( const SkyPoint& p1, const SkyPoint& p2 )
{
const SkyRegion& region = m_skyMesh->skyRegion( p1, p2 );
@@ -535,7 +539,7 @@ KSPlanetBase* SkyMapComposite::planet( int n ) {
if ( n == KSPlanetBase::NEPTUNE ) return (KSPlanetBase*)(m_SolarSystem->findByName( i18n( "Neptune" ) ) );
//if ( n == KSPlanetBase::PLUTO ) return (KSPlanetBase*)(m_SolarSystem->findByName( i18n( "Pluto" ) ) );
- return 0;
+ return 0;
}
void SkyMapComposite::addCustomCatalog( const QString &filename, int index ) {
@@ -572,13 +576,13 @@ void SkyMapComposite::reloadCLines( ) {
}
void SkyMapComposite::reloadCNames( ) {
-// Q_ASSERT( !SkyMapDrawAbstract::drawLock() );
-// SkyMapDrawAbstract::setDrawLock( true ); // This is not (yet) multithreaded, so I think we don't have to worry about overwriting the state of an existing lock --asimha
-// objectNames(SkyObject::CONSTELLATION).clear();
-// delete m_CNames;
-// m_CNames = 0;
-// m_CNames = new ConstellationNamesComponent( this, m_Cultures );
-// SkyMapDrawAbstract::setDrawLock( false );
+ // Q_ASSERT( !SkyMapDrawAbstract::drawLock() );
+ // SkyMapDrawAbstract::setDrawLock( true ); // This is not (yet) multithreaded, so I think we don't have to worry about overwriting the state of an existing lock --asimha
+ // objectNames(SkyObject::CONSTELLATION).clear();
+ // delete m_CNames;
+ // m_CNames = 0;
+ // m_CNames = new ConstellationNamesComponent( this, m_Cultures );
+ // SkyMapDrawAbstract::setDrawLock( false );
objectNames(SkyObject::CONSTELLATION).clear();
delete m_CNames;
m_CNames = new ConstellationNamesComponent( this, m_Cultures );
@@ -620,8 +624,8 @@ void SkyMapComposite::reloadDeepSky() {
QStringList allcatalogs = Options::showCatalogNames();
for ( int i=0; i < allcatalogs.size(); ++ i ) {
m_CustomCatalogs->addComponent(
- new CatalogComponent( this, allcatalogs.at(i), false, i ), 5
- );
+ new CatalogComponent( this, allcatalogs.at(i), false, i ), 5
+ );
}
SkyMapDrawAbstract::setDrawLock(false);
#endif
@@ -636,7 +640,7 @@ bool SkyMapComposite::isLocalCNames() {
void SkyMapComposite::emitProgressText( const QString &message ) {
emit progressText( message );
#ifndef Q_OS_ANDROID
-//Can cause crashes on Android, investigate it
+ //Can cause crashes on Android, investigate it
qApp->processEvents(); // -jbb: this seemed to make it work.
#endif
//qDebug() << QString("PROGRESS TEXT: %1\n").arg( message );
@@ -669,6 +673,63 @@ const QList<SkyObject*>& SkyMapComposite::supernovae() const
return m_Supernovae->objectList();
}
+QList<SkyObject*> SkyMapComposite::planets()
+{
+ return solarSystemComposite()->planetObjects();
+}
+
+//Store it permanently
+QList<SkyObject*> SkyMapComposite::moons()
+{
+ QList<SkyObject*> skyObjects;
+ foreach(PlanetMoonsComponent *pMoons, m_SolarSystem->planetMoonsComponent()) {
+ PlanetMoons *moons = pMoons->getMoons();
+ for(int i = 0; i < moons->nMoons(); ++i) {
+ skyObjects.append(moons->moon(i));
+ }
+ }
+ return skyObjects;
+}
+
+const QList<SkyObject*> *SkyMapComposite::getSkyObjectsList(SkyObject::TYPE t) {
+ switch(t) {
+ case SkyObject::STAR:
+ return &m_Stars->objectList();
+ break;
+ case SkyObject::CATALOG_STAR:
+ return nullptr;
+ break;
+ case SkyObject::PLANET:
+ return &m_SolarSystem->planetObjects();
+ break;
+ case SkyObject::COMET:
+ return &comets();
+ break;
+ case SkyObject::ASTEROID:
+ return &asteroids();
+ break;
+ case SkyObject::MOON:
+ return &m_SolarSystem->moons();
+ break;
+ case SkyObject::GALAXY:
+ case SkyObject::PLANETARY_NEBULA:
+ case SkyObject::GASEOUS_NEBULA:
+ case SkyObject::GLOBULAR_CLUSTER:
+ case SkyObject::OPEN_CLUSTER:
+ return nullptr;
+ break;
+ case SkyObject::CONSTELLATION:
+ return &constellationNames();
+ break;
+ case SkyObject::SUPERNOVA:
+ return &supernovae();
+ break;
+ default:
+ return nullptr;
+ }
+ //return nullptr;
+}
+
KSPlanet* SkyMapComposite::earth() {
return m_SolarSystem->earth();
}
diff --git a/kstars/skycomponents/skymapcomposite.h b/kstars/skycomponents/skymapcomposite.h
index dc435fa..7138c03 100644
--- a/kstars/skycomponents/skymapcomposite.h
+++ b/kstars/skycomponents/skymapcomposite.h
@@ -22,6 +22,7 @@
#include "skycomposite.h"
#include "ksnumbers.h"
+#include "skyobject.h"
class SkyMesh;
class SkyLabeler;
@@ -205,6 +206,10 @@ public:
const QList<SkyObject*>& asteroids() const;
const QList<SkyObject*>& comets() const;
const QList<SkyObject*>& supernovae() const;
+ QList<SkyObject*> planets();
+ QList<SkyObject*> moons();
+
+ const QList<SkyObject*> *getSkyObjectsList(SkyObject::TYPE t);
KSPlanet* earth();
KSPlanetBase* planet( int n );
@@ -222,6 +227,7 @@ signals:
private:
virtual QHash<int, QStringList>& getObjectNames();
+ virtual QHash<int, QVector<QPair<QString, const SkyObject*>>>& getObjectLists();
CultureList *m_Cultures;
ConstellationBoundaryLines *m_CBoundLines;
@@ -254,6 +260,7 @@ private:
QList<SkyObject*> m_LabeledObjects;
QHash<int, QStringList> m_ObjectNames;
+ QHash<int, QVector<QPair<QString, const SkyObject*>>> m_ObjectLists;
QHash<QString, QString> m_ConstellationNames;
};
diff --git a/kstars/skycomponents/solarsystemcomposite.cpp b/kstars/skycomponents/solarsystemcomposite.cpp
index eb8f2da..18dcb6b 100644
--- a/kstars/skycomponents/solarsystemcomposite.cpp
+++ b/kstars/skycomponents/solarsystemcomposite.cpp
@@ -76,6 +76,24 @@ SolarSystemComposite::SolarSystemComposite(SkyComposite *parent ) :
m_planets.append(uranus);
m_planets.append(nep);
+ /*m_planetObjects.append(sun->planet());
+ m_planetObjects.append(moon->planet());
+ m_planetObjects.append(mercury->planet());
+ m_planetObjects.append(venus->planet());
+ m_planetObjects.append(mars->planet());
+ m_planetObjects.append(sat->planet());
+ m_planetObjects.append(jup->planet());
+ m_planetObjects.append(uranus->planet());
+ m_planetObjects.append(nep->planet());
+
+ foreach(PlanetMoonsComponent *pMoons, planetMoonsComponent()) {
+ PlanetMoons *moons = pMoons->getMoons();
+ for(int i = 0; i < moons->nMoons(); ++i) {
+ SkyObject *moon = moons->moon(i);
+ objectLists(SkyObject::MOON).append(QPair<QString, const SkyObject*>(moon->name(), moon));
+ }
+ }*/
+
addComponent( m_AsteroidsComponent = new AsteroidsComponent( this ), 7);
addComponent( m_CometsComponent = new CometsComponent( this ), 7);
}
@@ -143,6 +161,15 @@ const QList<SkyObject*>& SolarSystemComposite::comets() const {
return m_CometsComponent->objectList();
}
+const QList<SkyObject*>& SolarSystemComposite::planetObjects() const {
+ return m_planetObjects;
+}
+
+const QList<SkyObject*>& SolarSystemComposite::moons() const {
+ return m_moons;
+}
+
+
CometsComponent* SolarSystemComposite::cometsComponent()
{
return m_CometsComponent;
@@ -161,4 +188,3 @@ QList<PlanetMoonsComponent *> SolarSystemComposite::planetMoonsComponent() const
{
return QList <PlanetMoonsComponent *>({m_JupiterMoons});
}
-
diff --git a/kstars/skycomponents/solarsystemcomposite.h b/kstars/skycomponents/solarsystemcomposite.h
index 3b19d39..6d72456 100644
--- a/kstars/skycomponents/solarsystemcomposite.h
+++ b/kstars/skycomponents/solarsystemcomposite.h
@@ -47,6 +47,8 @@ public:
KSPlanet* earth() { return m_Earth; }
const QList<SkyObject*>& asteroids() const;
const QList<SkyObject*>& comets() const;
+ const QList<SkyObject*>& planetObjects() const;
+ const QList<SkyObject*>& moons() const;
bool selected();
@@ -65,7 +67,6 @@ public:
QList<PlanetMoonsComponent *> planetMoonsComponent() const;
const QList<SolarSystemSingleComponent *>& planets() const;
-
private:
KSPlanet *m_Earth;
KSSun *m_Sun;
@@ -74,6 +75,8 @@ private:
AsteroidsComponent *m_AsteroidsComponent;
CometsComponent *m_CometsComponent;
QList<SolarSystemSingleComponent *> m_planets;
+ QList<SkyObject *> m_planetObjects;
+ QList<SkyObject *> m_moons;
};
#endif
diff --git a/kstars/skycomponents/solarsystemsinglecomponent.cpp b/kstars/skycomponents/solarsystemsinglecomponent.cpp
index ba482a6..489f63b 100644
--- a/kstars/skycomponents/solarsystemsinglecomponent.cpp
+++ b/kstars/skycomponents/solarsystemsinglecomponent.cpp
@@ -44,15 +44,20 @@ SolarSystemSingleComponent::SolarSystemSingleComponent(SolarSystemComposite *par
m_Planet( kspb )
{
m_Planet->loadData();
- if ( ! m_Planet->name().isEmpty() )
+ if ( ! m_Planet->name().isEmpty() ) {
objectNames(m_Planet->type()).append( m_Planet->name() );
- if ( ! m_Planet->longname().isEmpty() && m_Planet->longname() != m_Planet->name() )
+ objectLists(m_Planet->type()).append( QPair<QString, const SkyObject*>(m_Planet->name(),m_Planet) );
+ }
+ if ( ! m_Planet->longname().isEmpty() && m_Planet->longname() != m_Planet->name() ) {
objectNames(m_Planet->type()).append( m_Planet->longname() );
+ objectLists(m_Planet->type()).append( QPair<QString, const SkyObject*>(m_Planet->longname(),m_Planet) );
+ }
}
SolarSystemSingleComponent::~SolarSystemSingleComponent()
{
removeFromNames( m_Planet );
+ removeFromLists( m_Planet );
delete m_Planet;
}
diff --git a/kstars/skycomponents/starcomponent.cpp b/kstars/skycomponents/starcomponent.cpp
index a8d0247..3fd7994 100644
--- a/kstars/skycomponents/starcomponent.cpp
+++ b/kstars/skycomponents/starcomponent.cpp
@@ -477,9 +477,12 @@ bool StarComponent::loadStaticData()
if ( ! name.isEmpty() && name != i18n("star")) {
objectNames(SkyObject::STAR).append( name );
+ objectLists(SkyObject::STAR).append(QPair<QString, const SkyObject*>(name,star));
}
if ( ! visibleName.isEmpty() && gname != name ) {
- objectNames(SkyObject::STAR).append( star -> gname(false) );
+ QString gName = star -> gname(false);
+ objectNames(SkyObject::STAR).append( gName );
+ objectLists(SkyObject::STAR).append(QPair<QString, const SkyObject*>(gName,star));
}
m_ObjectList.append( star );
diff --git a/kstars/skycomponents/supernovaecomponent.cpp b/kstars/skycomponents/supernovaecomponent.cpp
index 362d45a..affe6c4 100644
--- a/kstars/skycomponents/supernovaecomponent.cpp
+++ b/kstars/skycomponents/supernovaecomponent.cpp
@@ -65,6 +65,7 @@ void SupernovaeComponent::loadData()
//m_ObjectList.clear();
latest.clear();
objectNames(SkyObject::SUPERNOVA).clear();
+ objectLists(SkyObject::SUPERNOVA).clear();
//SN, Host Galaxy, Date, R.A., Dec., Offset, Mag., Disc.Ref., SN Position, Posn.Ref., Typ, SN, Discoverer(s)
QList< QPair<QString,KSParser::DataTypes> > sequence;
@@ -107,9 +108,11 @@ void SupernovaeComponent::loadData()
if (magnitude == KSParser::EBROKEN_FLOAT)
magnitude = 99.9;
- if (m_ObjectList.empty() || !findByName(serialNo))
+ Supernova *sup = static_cast<Supernova*>(findByName(serialNo));
+
+ if (m_ObjectList.empty() || !sup)
{
- Supernova *sup = new Supernova(ra, dec, date, magnitude, serialNo,
+ sup = new Supernova(ra, dec, date, magnitude, serialNo,
type, hostGalaxy, offset, discoverers);
sup->EquatorialToHorizontal(KStarsData::Instance()->lst(),
@@ -119,6 +122,7 @@ void SupernovaeComponent::loadData()
latest.append(sup);
}
+ if(sup) objectLists(SkyObject::SUPERNOVA).append(QPair<QString, const SkyObject*>(serialNo, sup));
objectNames(SkyObject::SUPERNOVA).append(serialNo);
}
//notifyNewSupernovae();
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index 16c5743..dcbd675 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -52,7 +52,11 @@
#include <QQuickWindow>
#include <QLinkedList>
#include <QQmlContext>
+
#include <QTapSensor>
+#include <QMagnetometer>
+#include <QCompass>
+#include <QRotationSensor>
namespace {
@@ -126,6 +130,18 @@ SkyMapLite::SkyMapLite(QQuickItem* parent)
m_tapSensor->setReturnDoubleTapEvents(true);
m_tapSensor->start();
+ m_magnetometer = new QMagnetometer(this);
+ m_magnetometer->setReturnGeoValues(true);
+ m_magnetometer->start();
+
+ m_compass = new QCompass(this);
+ m_compass->start();
+
+ m_rotation = new QRotationSensor(this);
+ m_rotation->start();
+
+ connect( m_magnetometer, SIGNAL( readingChanged() ), this, SLOT( slotCompassMove() ) );
+
KStarsLite::Instance()->qmlEngine()->rootContext()->setContextProperty("ClickedObject",ClickedObjectLite);
KStarsLite::Instance()->qmlEngine()->rootContext()->setContextProperty("ClickedPoint",ClickedPointLite);
@@ -322,7 +338,7 @@ void SkyMapLite::slotCenter() {
//If the requested object is below the opaque horizon, issue a warning message
//(unless user is already pointed below the horizon)
if ( Options::useAltAz() && Options::showGround() &&
- focus()->alt().Degrees() > -1.0 && focusPoint()->alt().Degrees() < -1.0 ) {
+ focus()->alt().Degrees() > -1.0 && focusPoint()->alt().Degrees() < -1.0 ) {
QString caption = i18n( "Requested Position Below Horizon" );
QString message = i18n( "The requested position is below the horizon.\nWould you like to go there anyway?" );
@@ -413,7 +429,7 @@ void SkyMapLite::slewFocus() {
slewing = true;
forceUpdate();
- qApp->processEvents(); //keep up with other stuff
+ //qApp->processEvents(); //keep up with other stuff
if ( Options::useAltAz() ) {
dX = destination()->az().Degrees() - focus()->az().Degrees();
@@ -530,6 +546,50 @@ void SkyMapLite::slotZoomDefault() {
setZoomFactor( DEFAULTZOOM );
}
+void SkyMapLite::slotOpenObject(SkyObject *skyObj) {
+ if ( Options::useAltAz() ) {
+ setDestinationAltAz( skyObj->altRefracted(), skyObj->az() );
+ } else {
+ setDestination( *skyObj );
+ }
+ ClickedObjectLite->setObject(skyObj);
+ emit objectChanged();
+}
+
+void SkyMapLite::slotCompassMove() {
+ /*if(m_compass->reading()->calibrationLevel() != 1) {
+ m_compass->reading()->setCalibrationLevel(1);
+ }*/
+ /*qDebug() << m_compass->reading()->azimuth();
+ qDebug() << focus()->alt().Degrees() << focus()->az().Degrees();
+ double az = m_compass->reading()->azimuth();*/
+ QMagnetometerReading *r = m_magnetometer->reading();
+ r->setCalibrationLevel(1);
+ if(r) {
+ double y = r->y();// >= 0 ? r->y() : 360 - abs(r->y());//360 - (r->y() + 180);
+ while(abs(y) < 1) y *= 10;
+ double z = r->z();// >= 0 ? r->z() : 360 - abs(r->z());
+ while(abs(z) < 1) z *= 10;
+ double x = r->x();
+ while(abs(x) < 1) x *= 10;
+
+ /*double alt = x;
+ double az = (z+y)/2;
+
+ if(abs(az - focus()->az().Degrees()) < 1) {
+ az = focus()->az().Degrees();
+ }
+
+ if(abs(alt - focus()->alt().Degrees()) < 1) {
+ alt = focus()->alt().Degrees();
+ }
+
+ setFocusAltAz(dms(alt),dms(az));
+ qDebug() << focus()->alt().Degrees() << focus()->az().Degrees();*/
+ qDebug() << x << y << z;
+ }
+}
+
void SkyMapLite::setZoomFactor(double factor) {
Options::setZoomFactor( KSUtils::clamp(factor, MINZOOM, MAXZOOM) );
@@ -602,7 +662,7 @@ void SkyMapLite::updateFocus() {
setDestination( *focus() );
}
- //Tracking on empty sky
+ //Tracking on empty sky
} else if ( Options::isTracking() && focusPoint() != NULL ) {
if ( Options::useAltAz() ) {
//Tracking on empty sky in Alt/Az mode
@@ -611,8 +671,8 @@ void SkyMapLite::updateFocus() {
setDestination( *focus() );
}
- // Not tracking and not slewing, let sky drift by
- // This means that horizontal coordinates are constant.
+ // Not tracking and not slewing, let sky drift by
+ // This means that horizontal coordinates are constant.
} else {
focus()->HorizontalToEquatorial(data->lst(), data->geo()->lat() );
}
@@ -629,6 +689,7 @@ void SkyMapLite::setupProjector() {
p.zoomFactor = Options::zoomFactor();
p.fillGround = Options::showGround();
Options::setProjection(Projector::Lambert);
+
//Check if we need a new projector
if( m_proj && Options::projection() == m_proj->type() )
m_proj->setViewParams(p);
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 85b8ce3..455c419 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -51,7 +51,11 @@ class TelescopeLite;
class SkyObjectLite;
class SkyPointLite;
+
class QTapSensor;
+class QMagnetometer;
+class QCompass;
+class QRotationSensor;
class QSGTexture;
@@ -425,12 +429,22 @@ public slots:
/** Set default zoom. */
void slotZoomDefault();
+ /**
+ * @short centres skyObj in SkyMap and opens context drawer with skyObj
+ */
+ void slotOpenObject(SkyObject *skyObj);
/** Object pointing for Printing Wizard done */
//void slotObjectSelected();
//void slotCancelLegendPreviewMode();
+ /**
+ * @short slotGyroMove called when m_gyroSensor got new reading. Moves focus of SkyMapLite according
+ * to coordinates received from gyroscope
+ */
+ void slotCompassMove();
+
signals:
/** Emitted by setDestination(), and connected to slewFocus(). Whenever the Destination
* point is changed, slewFocus() will iteratively step the Focus toward Destination
@@ -444,10 +458,10 @@ signals:
void zoomChanged();
/** Emitted when current object changed. */
- void objectChanged(SkyObjectLite *obj);
+ void objectChanged();
/** Emitted when pointing changed. (At least should) */
- void positionChanged(SkyPointLite *point);
+ void positionChanged();
/** Emitted when position under mouse changed. */
void mousePointChanged(SkyPoint*);
@@ -648,7 +662,12 @@ private:
bool m_fontSizeChanged;
// Used for drawing labels
QPainter m_painter;
+
+ //Sensors
QTapSensor *m_tapSensor;
+ QMagnetometer *m_magnetometer;
+ QCompass *m_compass;
+ QRotationSensor *m_rotation;
static int starColorMode;
diff --git a/kstars/skymapliteevents.cpp b/kstars/skymapliteevents.cpp
index a0afe44..159b7f7 100644
--- a/kstars/skymapliteevents.cpp
+++ b/kstars/skymapliteevents.cpp
@@ -46,6 +46,7 @@ void SkyMapLite::mousePressEvent( QMouseEvent *e ) {
//Find object nearest to clickedPoint()
double maxrad = 1000.0/Options::zoomFactor();
+ double zoom = Options::zoomFactor();
SkyObject* obj = data->skyComposite()->objectNearest( clickedPoint(), maxrad );
setClickedObject( obj );
if( obj )
@@ -73,9 +74,9 @@ void SkyMapLite::mousePressEvent( QMouseEvent *e ) {
} else {*/
// Show popup menu
if( clickedObject() ) {
- emit objectChanged(ClickedObjectLite);
+ emit objectChanged();
} else {
- emit positionChanged(ClickedPointLite);
+ emit positionChanged();
/* pmenu->createEmptyMenu( clickedPoint() );
pmenu->popup( QCursor::pos() );*/
}
@@ -226,10 +227,15 @@ void SkyMapLite::mouseMoveEvent( QMouseEvent *e ) {
}
void SkyMapLite::wheelEvent( QWheelEvent *e ) {
- if ( e->delta() > 0 )
+ if ( e->delta() > 0 ) {
zoomInOrMagStep ( e->modifiers() );
- else if ( e->delta() < 0 )
+ //setRotation(rotation() + 0.1); TEST
+ }
+ else if ( e->delta() < 0 ) {
zoomOutOrMagStep( e->modifiers() );
+ //setRotation(rotation() - 0.1); TEST
+ }
+
}
void SkyMapLite::touchEvent( QTouchEvent *e) {
@@ -343,6 +349,7 @@ void SkyMapLite::touchEvent( QTouchEvent *e) {
}
delete event;
} else if((e->touchPointStates() & (Qt::TouchPointReleased))) { //&& !slewing && points.length() == 1) {
+ if(slewing) slewing = false;
//Show tap animation
emit posClicked(points[0].screenPos());
//determine RA, Dec of touch
@@ -350,17 +357,18 @@ void SkyMapLite::touchEvent( QTouchEvent *e) {
setClickedPoint( &m_MousePoint );
//Find object nearest to clickedPoint()
- double maxrad = 2.5;/*1000.0/Options::zoomFactor()*2; /* On high zoom-level it is very hard to select the object using touch screen.
+ double maxrad = 1000.0/Options::zoomFactor(); /* On high zoom-level it is very hard to select the object using touch screen.
That's why radius remains constant*/
+ maxrad = qMax(maxrad,2.5);
qDebug() << maxrad << "maxrad";
SkyObject* obj = data->skyComposite()->objectNearest( clickedPoint(), maxrad );
setClickedObject( obj );
if( obj ) setClickedPoint( obj );
if( clickedObject() ) {
- emit objectChanged(ClickedObjectLite);
+ emit objectChanged();
} else {
- emit positionChanged(ClickedPointLite);
+ emit positionChanged();
}
}
}
diff --git a/kstars/skyobjects/skyobject.h b/kstars/skyobjects/skyobject.h
index 979e5fd..fd0e037 100644
--- a/kstars/skyobjects/skyobject.h
+++ b/kstars/skyobjects/skyobject.h
@@ -112,7 +112,7 @@ public:
GASEOUS_NEBULA=5, PLANETARY_NEBULA=6, SUPERNOVA_REMNANT=7, GALAXY=8,
COMET=9, ASTEROID=10, CONSTELLATION=11, MOON=12, ASTERISM=13,
GALAXY_CLUSTER=14, DARK_NEBULA=15, QUASAR=16, MULT_STAR=17, RADIO_SOURCE=18,
- SATELLITE=19, SUPERNOVA=20, TYPE_UNKNOWN=255 };
+ SATELLITE=19, SUPERNOVA=20, SOLAR_SYSTEM = 21, TYPE_UNKNOWN=255 };
/**
*@return A translated string indicating the type name for a given type number