Commit a4967723 authored by Samikshan Bairagya's avatar Samikshan Bairagya

Introducing feature "What's Interesting..." A QML based test interface has been designed.

SkyObjListModel is a subclass of QAbstractListModel. Objects of SkyObjListModel can
represent any sky-object(any type). Currently test models for Planets, Stars, Galaxies,
Constellations, Star Clusters and Nebulae are used in class Modelmanager. The QML UI is
maintained by the WIView class.

The models are loaded everytime "What's Interesting..." is opened. It takes a long
time to load all the models. This is because currently the models checks through all
sky-objects. A reduced list will definitely be required.
parent 10999473
add_subdirectory( data )
add_subdirectory( data )
add_subdirectory( icons )
add_subdirectory( htmesh )
add_subdirectory( htmesh )
add_subdirectory( tools/WhatsInteresting)
Find_package(ZLIB REQUIRED)
......@@ -124,6 +125,9 @@ set(libkstarstools_SRCS
tools/scriptfunction.cpp
tools/skycalendar.cpp
tools/wutdialog.cpp
tools/WhatsInteresting/skyobjlistmodel.cpp
tools/WhatsInteresting/WIView.cpp
tools/WhatsInteresting/modelmanager.cpp
tools/flagmanager.cpp
tools/moonphasetool.cpp
tools/starhopper.cpp
......@@ -436,6 +440,8 @@ target_link_libraries(kstars
${KDE4_KDECORE_LIBS}
${KDE4_KNEWSTUFF3_LIBS}
${KDE4_KIO_LIBS}
${QT_QTDECLARATIVE_LIBRARY}
kdeclarative
htmesh
${ZLIB_LIBRARIES}
)
......
......@@ -43,6 +43,7 @@ class imagesequence;
class AltVsTime;
class LCGenerator;
class WUTDialog;
class WIView;
class AstroCalc;
class SkyCalendar;
class ScriptBuilder;
......@@ -507,6 +508,9 @@ private slots:
/** action slot: open What's up tonight dialog */
void slotWUT();
/** action slot: open What's Interesting window */
void slotWI();
/** action slot: open Sky Calendar tool */
void slotCalendar();
......@@ -652,6 +656,7 @@ private:
Execute *execute;
AltVsTime *avt;
WUTDialog *wut;
WIView *wi;
SkyCalendar *skycal;
ScriptBuilder *sb;
PlanetViewer *pv;
......
......@@ -75,6 +75,7 @@
#include "tools/astrocalc.h"
#include "tools/altvstime.h"
#include "tools/wutdialog.h"
#include "tools/WhatsInteresting/WIView.h"
#include "tools/skycalendar.h"
#include "tools/scriptbuilder.h"
#include "tools/planetviewer.h"
......@@ -283,6 +284,11 @@ void KStars::slotWUT() {
wut->show();
}
void KStars::slotWI(){
kDebug()<<"In slotWI()";
wi = new WIView();
}
void KStars::slotCalendar() {
if ( ! skycal ) skycal = new SkyCalendar(this);
skycal->show();
......
......@@ -375,6 +375,9 @@ void KStars::initActions() {
actionCollection()->addAction("whats_up_tonight", this, SLOT( slotWUT() ) )
<< i18n("What's up Tonight...")
<< KShortcut(Qt::CTRL+Qt::Key_U );
actionCollection()->addAction("whats_interesting", this, SLOT( slotWI() ) )
<< i18n("What's Interesting...")
<< KShortcut(Qt::CTRL+Qt::Key_W );
actionCollection()->addAction("skycalendar", this, SLOT( slotCalendar() ) )
<< i18n("Sky Calendar...");
......
......@@ -74,6 +74,7 @@
<Action name="lightcurvegenerator" />
<Action name="altitude_vs_time" />
<Action name="whats_up_tonight" />
<Action name="whats_interesting" />
<Action name="ekos" />
<Action name="glossary" />
<Action name="scriptbuilder" />
......
......@@ -65,6 +65,7 @@
<Action name="lightcurvegenerator" />
<Action name="altitude_vs_time" />
<Action name="whats_up_tonight" />
<Action name="whats_interesting" />
<Action name="glossary" />
<Action name="scriptbuilder" />
<Action name="solarsystem" />
......
......@@ -66,6 +66,7 @@
<Action name="lightcurvegenerator" />
<Action name="altitude_vs_time" />
<Action name="whats_up_tonight" />
<Action name="whats_interesting" />
<Action name="glossary" />
<Action name="scriptbuilder" />
<Action name="solarsystem" />
......
import QtQuick 1.0
Rectangle {
id : base
width: 800
height: 550
gradient: Gradient {
GradientStop {
position: 0
color: "#000000"
}
GradientStop {
position: 1
color: "#3555e4"
}
}
Text {
id: title
x: 14
y: 25
width: 195
height: 35
color: "#dee8f1"
text: qsTr("What's Interesting...")
font.family: "Cantarell"
verticalAlignment: Text.AlignVCenter
font.pixelSize: 19
}
Rectangle {
id: rectangle1
x: 14
y: 504
width: 200
height: 31
color: "#00000000"
Text {
id: text1
color: "#ffffff"
text: qsTr("What's Interesting Settings")
font.underline: true
verticalAlignment: Text.AlignVCenter
anchors.fill: parent
font.pixelSize: 12
MouseArea {
id: mouse_area1
x: 0
y: 0
anchors.fill: parent
}
}
}
Rectangle {
objectName: "listContainer"
x: 14
y: 86
width: 305
height: 360
color: "#00000000"
border.color: "#ffffff"
ListView {
id: catListView
objectName: "catListObj"
anchors.fill: parent
visible: true
signal catListItemClicked(string category)
delegate: Item {
id: baseListItem
objectName: modelData
x: 5
height: 40
//property variant item: modelData
Text {
text: modelData
color: "#ffffff"
anchors.verticalCenter: parent.verticalCenter
font.bold: true
MouseArea {
anchors.fill: parent
onClicked: {
catListView.currentIndex = index
switch (catListView.currentItem.objectName)
{
case "Planets" :
case "Satellites" :
case "Star" :
case "Galaxies" :
case "Constellations" :
case "Star Clusters" :
case "Nebulae" :
catListView.visible = false
soListView.visible = true
break;
}
catListView.catListItemClicked(catListView.currentItem.objectName)
}
}
}
}
model: catListModel
// ListModel {
// id : catListModel
// }
}
ListView {
id: soListView
objectName: "soListObj"
anchors.fill: parent
signal soListItemClicked( string name, string category)
visible: false
delegate: Item {
id: soListItem
objectName: dispName
x: 5
height: 40
Text {
text: dispName
color: "#ffffff"
anchors.verticalCenter: parent.verticalCenter
font.bold: true
MouseArea {
anchors.fill: parent
onClicked: {
soListView.currentIndex = index
soListView.catListItemClicked(soListView.currentItem.objectName)
}
}
}
}
model: soListModel
}
}
Rectangle {
id: rectangle2
x: 422
y: 86
width: 342
height: 412
color: "#1d4397"
}
}
#install_files
install( FILES Base.qml
DESTINATION ${DATA_INSTALL_DIR}/kstars/tools/WhatsInteresting/ )
/***************************************************************************
wiview.cpp - K Desktop Planetarium
-------------------
begin : 2012/26/05
copyright : (C) 2012 by Samikshan Bairagya
email : samikshan@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 "QDeclarativeContext"
#include "WIView.h"
#include "QGraphicsObject"
WIView::WIView ( QObject *parent) : QObject(parent)
{
kDebug()<<"In constructor";
m = new ModelManager();
QDeclarativeView *baseView;
baseView = new QDeclarativeView();
ctxt = baseView->rootContext();
ctxt->setContextProperty("catListModel", QVariant::fromValue(m->returnCatListModel( ModelManager::BaseList )));
//baseListBox = new QDeclarativeView();
//kDebug()<<QUrl::fromLocalFile("Base.qml");
baseView->setSource(QUrl("/home/sam/kstars/kstars/tools/WhatsInteresting/Base.qml"));
baseObj = dynamic_cast<QObject *> (baseView->rootObject());
catListObj = baseObj->findChild<QObject *>("listContainer")->findChild<QObject *>("catListObj");
connect(catListObj, SIGNAL(catListItemClicked(QString)), this, SLOT(onCatListItemClicked(QString)));
soListObj = baseObj->findChild<QObject *>("listContainer")->findChild<QObject *>("soListObj");
//connect(soListObj, SIGNAL(soListItemClicked()));
// planetaryListView->setSource(QUrl::fromLocalFile("WIPlanetaryListView.qml"));
// QObject *planetaryListObj = planetaryListView->rootObject();
// deepSkyListView->setSource(QUrl::fromLocalFile("WIDeepSkyListView.qml"));
// QObject *deepSkyListObj = deepSkyListView->rootObject();
// skyObjListView = new QDeclarativeView();
// skyObjListView->rootContext()->setContextProperty("skyObjModel", m->returnModel(ModelManager::Planets));
// skyObjListView->setSource(QUrl("/home/sam/kstars/kstars/tools/WhatsInteresting/SkyObjListView.qml"));
//
// kDebug()<<skyObjListView->rootContext()->contextProperty("skyObjModel");
//skyObjListView->setParent(baseListBox);
//QObject *skyObjectListObj = dynamic_cast<QObject *> (skyObjListView->rootObject());
//skyObjectListObj->setParent(listBoxObj);
baseView->show();
//skyObjectListObj->setParent(baseObj);
//skyObjectListObj->setProperty("skyObjModel", m->returnModel(2));
}
WIView::~WIView() {}
void WIView::onCatListItemClicked(QString category)
{
kDebug()<<"inSlot";
kDebug()<<category;
if (category == "Planetary Objects")
{
kDebug()<<"Planetary Objects";
ctxt->setContextProperty("catListModel", QVariant::fromValue(m->returnCatListModel( ModelManager::PlanetaryObjects )));
}
else if (category == "Deep-sky Objects")
{
ctxt->setContextProperty("catListModel", QVariant::fromValue(m->returnCatListModel( ModelManager::DeepSkyObjects )));
}
else if (category == "Planets")
{
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Planets ));
}
else if (category == "Stars")
{
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Stars ));
}
else if (category == "Galaxies")
{
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Galaxies ));
}
else if (category == "Constellations")
{
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Constellations ));
}
else if (category == "Star Clusters")
{
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Star_Clusters ));
}
else if (category == "Nebulae")
{
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Nebulae ));
}
}
/***************************************************************************
wiview.h - K Desktop Planetarium
-------------------
begin : 2012/26/05
copyright : (C) 2012 by Samikshan Bairagya
email : samikshan@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 "skyobjectitem.h"
#include "QtDeclarative/QDeclarativeView"
#include "QModelIndex"
#include "skyobject.h"
#include "modelmanager.h"
#include "skyobjlistmodel.h"
class WIView : public QObject
{
Q_OBJECT
public:
enum TYPE {PLANET, SATELLITE, STAR, GALAXY, CONSTELLATION, STAR_CLUSTER, NEBULA};
enum DetailViewType {PLANETARY};
WIView(QObject *parent = 0);
~WIView();
void manageViews(int TYPE); //display view
void loadDetailsView( int detailsViewType, SkyObject *so);
public slots:
// void loadModel ( int TYPE );
// void skyObjectItemClicked(QModelIndex index);
void onCatListItemClicked(QString);
private:
QObject *baseObj, *catListObj, *soListObj;
QDeclarativeContext *ctxt;
QDeclarativeView *baseListView;
QDeclarativeView *planetaryListView;
QDeclarativeView *deepSkyListView;
QDeclarativeView *skyObjListView;
QDeclarativeView *planetDetailsView;
QDeclarativeView *satelliteDetailsView;
QDeclarativeView *deepSkyDetailsView;
ModelManager *m;
};
\ No newline at end of file
/***************************************************************************
modelmanager.cpp - K Desktop Planetarium
-------------------
begin : 2012/26/05
copyright : (C) 2012 by Samikshan Bairagya
email : samikshan@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 "modelmanager.h"
//#include "skyobjectitem.h"
#include "kstarsdata.h"
#include "skymapcomposite.h"
#include "skyobject.h"
ModelManager::ModelManager()
{
planetsModel = new SkyObjListModel();
starsModel = new SkyObjListModel();
galModel = new SkyObjListModel();
conModel = new SkyObjListModel();
starClustModel = new SkyObjListModel();
nebModel = new SkyObjListModel();
updateModels();
}
void ModelManager::updateModels()
{
KStarsData *data = KStarsData::Instance();
baseCatList<<"Planetary Objects"<<"Deep-sky Objects" ;
planetaryList<<"Planets"<<"Satellites";
deepSkyList<<"Stars"<<"Galaxies"<<"Constellations"<<"Star Clusters"<<"Nebulae";
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::PLANET ) )
{
SkyObject *o = data->skyComposite()->findByName( name );
kDebug()<<o->name()<<o->mag();
if (o->mag() < 7)
{
// SkyObjectItem *planetItem = new SkyObjectItem(o);
// planetItem->setText(o->name());
planetsModel->addSkyObject(o);
}
}
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::STAR ) )
{
SkyObject *o = data->skyComposite()->findByName( name );
kDebug()<<o->name()<<o->mag();
if (o->mag() < 2)
{
// SkyObjectItem *planetItem = new SkyObjectItem(o);
// planetItem->setText(o->name());
starsModel->addSkyObject(o);
}
}
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::GALAXY ) )
{
SkyObject *o = data->skyComposite()->findByName( name );
kDebug()<<o->name()<<o->mag();
if (o->mag() < 2)
{
// SkyObjectItem *planetItem = new SkyObjectItem(o);
// planetItem->setText(o->name());
galModel->addSkyObject(o);
}
}
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::CONSTELLATION ) )
{
SkyObject *o = data->skyComposite()->findByName( name );
kDebug()<<o->name()<<o->mag();
if (o->mag() < 2)
{
// SkyObjectItem *planetItem = new SkyObjectItem(o);
// planetItem->setText(o->name());
conModel->addSkyObject(o);
}
}
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::OPEN_CLUSTER ) )
{
SkyObject *o = data->skyComposite()->findByName( name );
kDebug()<<o->name()<<o->mag();
if (o->mag() < 2)
{
// SkyObjectItem *planetItem = new SkyObjectItem(o);
// planetItem->setText(o->name());
starClustModel->addSkyObject(o);
}
}
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::PLANETARY_NEBULA ) )
{
SkyObject *o = data->skyComposite()->findByName( name );
kDebug()<<o->name()<<o->mag();
if (o->mag() < 2)
{
// SkyObjectItem *planetItem = new SkyObjectItem(o);
// planetItem->setText(o->name());
nebModel->addSkyObject(o);
}
}
}
SkyObjListModel* ModelManager::returnModel(ModelManager::LIST_TYPE Type)
{
if (Type == Planets)
return planetsModel;
else if (Type == Stars)
return starsModel;
else if (Type == Galaxies)
return galModel;
else if (Type == Constellations)
return conModel;
else if (Type == Star_Clusters)
return starClustModel;
else if (Type == Nebulae)
return nebModel;
return (new SkyObjListModel());
}
QStringList ModelManager::returnCatListModel(ModelManager::LIST_TYPE Type)
{
if (Type == BaseList)
return baseCatList;
else if ( Type == PlanetaryObjects )
return planetaryList;
else
return deepSkyList;
}
/***************************************************************************
modelmanager.h - K Desktop Planetarium
-------------------
begin : 2012/26/05
copyright : (C) 2012 by Samikshan Bairagya
email : samikshan@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 <QStandardItemModel>
#include "skyobjlistmodel.h"
class ModelManager
{
public:
enum LIST_TYPE {BaseList, PlanetaryObjects, DeepSkyObjects, Planets, Satellites,
Stars, Galaxies, Constellations, Star_Clusters, Nebulae};
ModelManager();
~ModelManager();
void updateModels();
//void setModelToListView( QStandardItemModel* myModel );
//QStandardItemModel* returnModel ( int TYPE );
SkyObjListModel* returnModel ( LIST_TYPE Type );
QStringList returnCatListModel ( LIST_TYPE Type );