Commit 490b49b5 authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq

This patch addresses several key issues with whats interesting. First, on...

This patch addresses several key issues with whats interesting.  First, on Macs it will first check inside the app bundle for the whats interesting before it checks in the data directory.  That way if the user installed from a dmg and then updated to a new dmg the any whats interesting improvements will be included.  It still checks the data directory as a backup in case the user didn’t install from a dmg. Second, when there are no objects in a list, it displays a nice message explaining that, rather than just a blank screen.  Also I added Supernovas, the NGC Catalog, the IC Catalog, and the Sharpless Catalog.  I also added some more objects to the object lists.  For the catalogs, I made them load separately on demand with a nice progress bar and a message explaining that they are loading.  Also I corrected a bug for the moon and similar objects that were not object types originally included in Whats Interesting.  I also disabled automatic downloading for object information because I don’t think it should be initiating lots of network traffic when there is no internet connection and also it shouldn’t try to download data many many times for objects that really have no article.  The user can now initiate the download of all the data for the entire list, for individual objects, or just objects that have no data, so that should be fine.  I also did a little rearranging on the category screen.  Also just in case, I added some checks to see if some objects are null for safety.

CCMAIL:kstars-devel@kde.org
parent b5a3f4ae
......@@ -115,6 +115,7 @@ void ModelManager::loadLists()
loadObjectList(m_ObjectList[Comets], SkyObject::COMET);
emit loadProgressUpdated(0.40);
loadObjectList(m_ObjectList[Satellites], SkyObject::SATELLITE);
loadObjectList(m_ObjectList[Supernovas], SkyObject::SUPERNOVA);
emit loadProgressUpdated(0.50);
loadObjectList(m_ObjectList[Constellations], SkyObject::CONSTELLATION);
emit loadProgressUpdated(0.55);
......@@ -130,6 +131,7 @@ void ModelManager::loadLists()
emit loadProgressUpdated(0.80);
loadObjectList(m_ObjectList[Nebulas], SkyObject::PLANETARY_NEBULA);
loadObjectList(m_ObjectList[Nebulas], SkyObject::SUPERNOVA_REMNANT);
loadObjectList(m_ObjectList[Nebulas], SkyObject::GASEOUS_NEBULA);
loadObjectList(m_ObjectList[Nebulas], SkyObject::DARK_NEBULA);
......@@ -142,16 +144,59 @@ void ModelManager::loadLists()
if ((o = data->skyComposite()->findByName("M " + QString::number(i))))
m_ObjectList[Messier].append(new SkyObjItem(o));
}
emit loadProgressUpdated(1);
/**
Note: The sharpless catalog did not have good wikipedia articles
for(int i=1;i<=350;i++)
{
SkyObject * o;
if ((o = data->skyComposite()->findByName("Sh2 " + QString::number(i))))
m_SharplessModel->addSkyObject(new SkyObjItem(o));
}
void ModelManager::loadNGCCatalog(){
KStarsData * data = KStarsData::Instance();
if(!ngcLoaded){
for(int i=1;i<=7840;i++)
{
if(i%100==0)
emit loadProgressUpdated((double)i/7840.0);
SkyObject * o;
if ((o = data->skyComposite()->findByName("NGC " + QString::number(i))))
m_ObjectList[NGC].append(new SkyObjItem(o));
}
updateModel(m_ObsConditions,"ngc");
emit loadProgressUpdated(1);
}
ngcLoaded = true;
}
void ModelManager::loadICCatalog(){
KStarsData * data = KStarsData::Instance();
if(!icLoaded){
for(int i=1;i<=3866;i++)
{
if(i%100==0)
emit loadProgressUpdated((double)i/3866.0);
SkyObject * o;
if ((o = data->skyComposite()->findByName("IC " + QString::number(i))))
m_ObjectList[IC].append(new SkyObjItem(o));
}
updateModel(m_ObsConditions,"ic");
emit loadProgressUpdated(1);
}
icLoaded = true;
}
void ModelManager::loadSharplessCatalog(){
KStarsData * data = KStarsData::Instance();
if(!sharplessLoaded){
for(int i=1;i<=320;i++)
{
if(i%100==0)
emit loadProgressUpdated((double)i/320.0);
SkyObject * o;
if ((o = data->skyComposite()->findByName("Sh2 " + QString::number(i))))
m_ObjectList[Sharpless].append(new SkyObjItem(o));
}
updateModel(m_ObsConditions,"sharpless");
emit loadProgressUpdated(1);
}
**/
sharplessLoaded = true;
}
void ModelManager::updateAllModels(ObsConditions * obs)
......@@ -176,6 +221,7 @@ void ModelManager::updateModel(ObsConditions * obs, QString modelName){
loadObjectsIntoModel(*m_ModelList[getModelNumber(modelName)], favoriteClusters);
else
loadObjectsIntoModel(*m_ModelList[getModelNumber(modelName)], m_ObjectList[getModelNumber(modelName)]);
emit modelUpdated();
}
}
......@@ -236,10 +282,16 @@ int ModelManager::getModelNumber(QString modelName){
return Asteroids;
if(modelName=="comets")
return Comets;
if(modelName=="supernovas")
return Supernovas;
if(modelName=="satellites")
return Satellites;
if(modelName=="messier")
return Messier;
if(modelName=="ngc")
return NGC;
if(modelName=="ic")
return IC;
if(modelName=="sharpless")
return Sharpless;
else return -1;
......
......@@ -36,7 +36,7 @@ class ModelManager: public QObject
* \enum ModelType
* \brief Model type for different types of sky-objects.
*/
enum ObjectList {Planets, Stars, Constellations, Galaxies, Clusters, Nebulas, Satellites, Asteroids, Comets, Messier, Sharpless, NumberOfLists};
enum ObjectList {Planets, Stars, Constellations, Galaxies, Clusters, Nebulas, Satellites, Asteroids, Comets, Supernovas, Messier, NGC, IC, Sharpless, NumberOfLists};
/**
* \brief Constructor - Creates models for different sky-object types.
......@@ -86,10 +86,18 @@ class ModelManager: public QObject
int getModelNumber(QString modelName);
SkyObjListModel * getTempModel(){ return tempModel;}
SkyObjListModel * getTempModel(){ return tempModel; }
void loadNGCCatalog();
void loadICCatalog();
void loadSharplessCatalog();
bool isNGCLoaded(){ return ngcLoaded; }
bool isICLoaded(){ return icLoaded; }
bool isSharplessLoaded(){ return sharplessLoaded; }
signals:
void loadProgressUpdated(double progress);
void modelUpdated();
private:
ObsConditions * m_ObsConditions;
......@@ -105,6 +113,9 @@ class ModelManager: public QObject
QList <SkyObjItem *> favoriteNebulas;
QList <SkyObjItem *> favoriteClusters;
SkyObjListModel * tempModel;
bool ngcLoaded = false;
bool icLoaded = false;
bool sharplessLoaded = false;
};
......
......@@ -23,18 +23,21 @@
#include "ksutils.h"
#include "kspaths.h"
SkyObjItem::SkyObjItem(SkyObject * so) : m_Name(so->name()), m_LongName(so->longname()),m_TypeName(so->typeName()), m_So(so), skd(NULL)
SkyObjItem::SkyObjItem(SkyObject * so) : m_Name(so->name()), m_LongName(so->longname()),m_TypeName(so->typeName()), m_So(so)
{
switch (so->type())
{
case SkyObject::PLANET:
case SkyObject::MOON:
m_Type = Planet;
break;
case SkyObject::STAR:
skd = new SkyObjDescription(m_Name, m_TypeName);
case SkyObject::CATALOG_STAR:
case SkyObject::MULT_STAR:
m_Type = Star;
break;
case SkyObject::CONSTELLATION:
case SkyObject::ASTERISM:
m_Type = Constellation;
break;
case SkyObject::GALAXY:
......@@ -46,10 +49,13 @@ SkyObjItem::SkyObjItem(SkyObject * so) : m_Name(so->name()), m_LongName(so->long
m_Type = Cluster;
break;
case SkyObject::PLANETARY_NEBULA:
case SkyObject::SUPERNOVA_REMNANT:
case SkyObject::GASEOUS_NEBULA:
case SkyObject::DARK_NEBULA:
m_Type = Nebula;
break;
case SkyObject::SUPERNOVA:
m_Type = Supernova;
}
setPosition(m_So);
......@@ -57,7 +63,7 @@ SkyObjItem::SkyObjItem(SkyObject * so) : m_Name(so->name()), m_LongName(so->long
SkyObjItem::~SkyObjItem()
{
delete skd;
}
QVariant SkyObjItem::data(int role)
......
......@@ -40,7 +40,7 @@ class SkyObjItem
* \enum Type
* The type classification for the SkyObjItem
*/
enum Type { Planet, Star, Constellation, Galaxy, Cluster, Nebula };
enum Type { Planet, Star, Constellation, Galaxy, Cluster, Nebula, Supernova };
/**
* \brief Constructor
......
......@@ -28,6 +28,7 @@
#include "Options.h"
#include "wiequipsettings.h"
#include "skymapcomposite.h"
#include <QtConcurrent>
#ifdef HAVE_INDI
......@@ -66,12 +67,23 @@ WIView::WIView(QWidget * parent) : QWidget(parent), m_CurrentObjectListName(-1)
///Use instead of KDeclarative
m_Ctxt->setContextObject(new KLocalizedContext(m_BaseView));
m_BaseView->setSource(QUrl::fromLocalFile(KSPaths::locate(QStandardPaths::AppDataLocation, "tools/whatsinteresting/qml/wiview.qml")));
QString WI_Location="";
#ifdef Q_OS_OSX
WI_Location = QCoreApplication::applicationDirPath()+"/../Resources/data/tools/whatsinteresting/qml/wiview.qml";
if(!QFileInfo(WI_Location).exists())
WI_Location = KSPaths::locate(QStandardPaths::AppDataLocation, "tools/whatsinteresting/qml/wiview.qml");
#else
WI_Location = KSPaths::locate(QStandardPaths::AppDataLocation, "tools/whatsinteresting/qml/wiview.qml");
#endif
m_BaseView->setSource(QUrl::fromLocalFile(WI_Location));
m_BaseObj = m_BaseView->rootObject();
m_ProgressBar = m_BaseObj->findChild<QQuickItem *>("progressBar");
m_loadingMessage = m_BaseObj->findChild<QQuickItem *>("loadingMessage");
m_CategoryTitle = m_BaseObj->findChild<QQuickItem *>(QString("categoryTitle"));
m_ViewsRowObj = m_BaseObj->findChild<QQuickItem *>(QString("viewsRowObj"));
......@@ -127,6 +139,7 @@ WIView::WIView(QWidget * parent) : QWidget(parent), m_CurrentObjectListName(-1)
setProgressBarVisible(true);
connect(m_ModManager, SIGNAL(loadProgressUpdated(double)),this,SLOT(updateProgress(double)));
connect(m_ModManager, SIGNAL(modelUpdated()),this,SLOT(refreshListView()));
m_ViewsRowObj->setProperty("enabled",false);
}
......@@ -144,9 +157,14 @@ void WIView::setProgressBarVisible(bool visible){
void WIView::updateProgress(double value){
m_ProgressBar->setProperty("value", value);
if(value==1){
setProgressBarVisible(false);
m_ViewsRowObj->setProperty("enabled",true);
m_loadingMessage->setProperty("state", "");
} else{
setProgressBarVisible(true);
m_loadingMessage->setProperty("state", "loading");
}
}
......@@ -191,13 +209,25 @@ void WIView::updateObservingConditions(){
void WIView::onCategorySelected(QString model)
{
m_CurrentObjectListName = model;
updateModel(m_Obs);
m_Ctxt->setContextProperty("soListModel", m_ModManager->returnModel(model));
m_Ctxt->setContextProperty("soListModel", m_ModManager->returnModel(m_CurrentObjectListName));
m_CurIndex = -2;
if(!m_ModManager->showOnlyVisibleObjects())
visibleIconObj->setProperty("state","unchecked");
if(!m_ModManager->showOnlyFavoriteObjects())
favoriteIconObj->setProperty("state","unchecked");
onSoListItemClicked(0);
if(model=="ngc"&&(!m_ModManager->isNGCLoaded())){
QtConcurrent::run(m_ModManager,&ModelManager::loadNGCCatalog);
return;
}
if(model=="ic"&&(!m_ModManager->isICLoaded())){
QtConcurrent::run(m_ModManager,&ModelManager::loadICCatalog);
return;
}
if(model=="sharpless"&&(!m_ModManager->isSharplessLoaded())){
QtConcurrent::run(m_ModManager,&ModelManager::loadSharplessCatalog);
return;
}
updateModel(m_Obs);
}
void WIView::onSoListItemClicked(int index)
......@@ -209,16 +239,20 @@ void WIView::onSoListItemClicked(int index)
void WIView::onNextObjClicked()
{
int modelSize = m_ModManager->returnModel(m_CurrentObjectListName)->rowCount();
SkyObjItem * nextItem = m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex+1)%modelSize);
loadDetailsView(nextItem, (m_CurIndex+1)%modelSize);
if( m_CurrentObjectListName!=""){
int modelSize = m_ModManager->returnModel(m_CurrentObjectListName)->rowCount();
SkyObjItem * nextItem = m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex+1)%modelSize);
loadDetailsView(nextItem, (m_CurIndex+1)%modelSize);
}
}
void WIView::onPrevObjClicked()
{
int modelSize = m_ModManager->returnModel(m_CurrentObjectListName)->rowCount();
SkyObjItem * prevItem = m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex-1+modelSize)%modelSize);
loadDetailsView(prevItem, (m_CurIndex-1+modelSize)%modelSize);
if( m_CurrentObjectListName!=""){
int modelSize = m_ModManager->returnModel(m_CurrentObjectListName)->rowCount();
SkyObjItem * prevItem = m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex-1+modelSize)%modelSize);
loadDetailsView(prevItem, (m_CurIndex-1+modelSize)%modelSize);
}
}
void WIView::onCenterButtonClicked()
......@@ -291,9 +325,11 @@ void WIView::onDetailsButtonClicked()
///Code taken from WUTDialog::slotDetails()
KStars * kstars = KStars::Instance();
SkyObject * so = m_CurSoItem->getSkyObject();
DetailDialog * detail = new DetailDialog(so, kstars->data()->lt(), kstars->data()->geo(), kstars);
detail->exec();
delete detail;
if(so){
DetailDialog * detail = new DetailDialog(so, kstars->data()->lt(), kstars->data()->geo(), kstars);
detail->exec();
delete detail;
}
}
void WIView::onSettingsIconClicked()
......@@ -305,7 +341,8 @@ void WIView::onSettingsIconClicked()
void WIView::onReloadIconClicked()
{
updateModel(m_Obs);
m_CurIndex=m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjIndex(m_CurSoItem);
if(m_CurrentObjectListName!="")
m_CurIndex=m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjIndex(m_CurSoItem);
loadDetailsView(m_CurSoItem, m_CurIndex);
}
......@@ -325,12 +362,15 @@ void WIView::onUpdateIconClicked(){
QMessageBox mbox;
mbox.setText( "Please choose which object(s) to try to update with Wikipedia data." );
QPushButton * currentObject = mbox.addButton("Current Object" , QMessageBox::AcceptRole);
QPushButton * missingObjects = mbox.addButton("Objects with no data" , QMessageBox::AcceptRole);
QPushButton * allObjects = mbox.addButton("Entire List" , QMessageBox::AcceptRole);
QPushButton * missingObjects;
QPushButton * allObjects;
if(m_CurrentObjectListName!=""){
missingObjects = mbox.addButton("Objects with no data" , QMessageBox::AcceptRole);
allObjects = mbox.addButton("Entire List" , QMessageBox::AcceptRole);
}
QPushButton * cancel = mbox.addButton( "Cancel", QMessageBox::AcceptRole );
mbox.setDefaultButton(cancel);
mbox.exec();
if(mbox.clickedButton()==currentObject)
{
......@@ -357,6 +397,8 @@ void WIView::refreshListView(){
m_Ctxt->setContextProperty("soListModel",0);
if (m_CurrentObjectListName !="")
m_Ctxt->setContextProperty("soListModel", m_ModManager->returnModel(m_CurrentObjectListName));
if(m_CurIndex==-2)
onSoListItemClicked(0);
if(m_CurIndex!=-1)
m_SoListObj->setProperty("currentIndex", m_CurIndex);
}
......@@ -365,7 +407,6 @@ void WIView::updateModel(ObsConditions * obs)
{
m_Obs = obs;
m_ModManager->updateModel(m_Obs,m_CurrentObjectListName);
refreshListView();
}
void WIView::inspectSkyObject(QString name){
......@@ -377,6 +418,7 @@ void WIView::inspectSkyObject(QString name){
void WIView::inspectSkyObject(SkyObject *obj){
if(obj){
if(obj->name()!="star"){
m_CurrentObjectListName="";
loadDetailsView(new SkyObjItem(obj),-1);
m_BaseObj->setProperty("state", "singleItemSelected");
m_CategoryTitle->setProperty("text", "Selected Object");
......@@ -386,6 +428,8 @@ void WIView::inspectSkyObject(SkyObject *obj){
void WIView::loadDetailsView(SkyObjItem * soitem, int index)
{
if(!soitem)
return;
m_CurSoItem = soitem;
m_CurIndex = index;
int modelSize;
......@@ -423,7 +467,7 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index)
loadObjectDescription(soitem);
infoBoxText->setProperty("text", "trying to Load infoText box from Wikipedia. . .");
infoBoxText->setProperty("text", "<BR><BR>No Wikipedia information. <BR> Please try to download it using the orange download button below.");
loadObjectInfoBox(soitem);
QString summary=soitem->getSummary(false);
......@@ -451,6 +495,8 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index)
}
QString WIView::getWikipediaName(SkyObjItem *soitem){
if(!soitem)
return "";
QString name;
if(soitem->getName().toLower().startsWith("m "))
name = soitem->getName().replace("M ","Messier_").remove( ' ' );
......@@ -490,6 +536,8 @@ QString WIView::getWikipediaName(SkyObjItem *soitem){
void WIView::updateWikipediaDescription(SkyObjItem * soitem)
{
if(!soitem)
return;
QString name=getWikipediaName(soitem);
QUrl url("https://en.wikipedia.org/w/api.php?action=opensearch&search=" + name + "&format=xml");
......@@ -550,6 +598,8 @@ void WIView::loadObjectDescription(SkyObjItem * soitem){
void WIView::loadObjectInfoBox(SkyObjItem * soitem)
{
if(!soitem)
return;
QFile file;
QString fname = "infoText-" + soitem->getName().toLower().remove( ' ' ) + ".html";
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "descriptions/" + fname ) ; //determine filename in local user KDE directory tree.
......@@ -578,10 +628,6 @@ void WIView::loadObjectInfoBox(SkyObjItem * soitem)
file.close();
}
}
else
{
tryToUpdateWikipediaInfo(soitem, getWikipediaName(soitem));
}
}
void WIView::tryToUpdateWikipediaInfoInModel(bool onlyMissing){
......@@ -603,7 +649,7 @@ void WIView::tryToUpdateWikipediaInfoInModel(bool onlyMissing){
void WIView::tryToUpdateWikipediaInfo(SkyObjItem * soitem, QString name)
{
if(name=="")
if(name==""||!soitem)
return;
QUrl url("https://en.wikipedia.org/w/index.php?action=render&title="+ name + "&redirects");
......
......@@ -144,7 +144,7 @@ class WIView : public QWidget
private:
QQuickItem * m_BaseObj, *m_ViewsRowObj, *m_CategoryTitle, *m_SoListObj, *m_DetailsViewObj, *m_skyObjView, *m_ContainerObj, *m_ProgressBar,
QQuickItem * m_BaseObj, *m_ViewsRowObj, *m_CategoryTitle, *m_SoListObj, *m_DetailsViewObj, *m_skyObjView, *m_ContainerObj, *m_ProgressBar, *m_loadingMessage,
*m_NextObj, *m_PrevObj, *m_CenterButtonObj, *m_SlewTelescopeButtonObj, *m_DetailsButtonObj, * visibleIconObj, * favoriteIconObj;
QQmlContext * m_Ctxt;
QObject * infoBoxText, * descTextObj;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment