Commit abe02101 authored by Samikshan Bairagya's avatar Samikshan Bairagya

Fixed some issues related to naming conventions and code formatting.

parent 4bb45e71
......@@ -198,7 +198,7 @@ kde4_add_ui_files(libkstarstools_SRCS
)
set(libkstarscomponents_SRCS
set(libkstarscomponents_SRCS
skycomponents/skylabeler.cpp
skycomponents/highpmstarlist.cpp
skycomponents/skymapcomposite.cpp
......
......@@ -23,36 +23,36 @@
ModelManager::ModelManager(ObsConditions *obs)
{
obsconditions = obs;
planetsModel = new SkyObjListModel();
starsModel = new SkyObjListModel();
galModel = new SkyObjListModel();
conModel = new SkyObjListModel();
clustModel = new SkyObjListModel();
nebModel = new SkyObjListModel();
initobjects[Star_Model] = QList<SkyObject *>();
initobjects[Galaxy_Model] = QList<SkyObject *>();
initobjects[Constellation_Model] = QList<SkyObject *>();
initobjects[Cluster_Model] = QList<SkyObject *>();
initobjects[Nebula_Model] = QList<SkyObject *>();
m_ObsConditions = obs;
m_PlanetsModel = new SkyObjListModel();
m_StarsModel = new SkyObjListModel();
m_GalModel = new SkyObjListModel();
m_ConModel = new SkyObjListModel();
m_ClustModel = new SkyObjListModel();
m_NebModel = new SkyObjListModel();
m_InitObjects[Star_Model] = QList<SkyObject *>();
m_InitObjects[Galaxy_Model] = QList<SkyObject *>();
m_InitObjects[Constellation_Model] = QList<SkyObject *>();
m_InitObjects[Cluster_Model] = QList<SkyObject *>();
m_InitObjects[Nebula_Model] = QList<SkyObject *>();
updateModels(obs);
}
ModelManager::~ModelManager()
{
delete planetsModel;
delete starsModel;
delete galModel;
delete conModel;
delete clustModel;
delete nebModel;
delete m_PlanetsModel;
delete m_StarsModel;
delete m_GalModel;
delete m_ConModel;
delete m_ClustModel;
delete m_NebModel;
}
void ModelManager::updateModels(ObsConditions *obs)
{
obsconditions = obs;
initobjects.clear();
m_ObsConditions = obs;
m_InitObjects.clear();
resetModels();
KStarsData *data = KStarsData::Instance();
......@@ -64,79 +64,77 @@ void ModelManager::updateModels(ObsConditions *obs)
{
QString line = fileReader.readLine();
if (line[0] == '#' || line.length() == 0)
if (line.length() == 0 || line[0] == '#')
continue;
SkyObject *o;
if ((o = data->skyComposite()->findByName(line)))
{
//kDebug()<<o->longname()<<o->typeName();
if (o->type() == SkyObject::OPEN_CLUSTER ||
o->type() == SkyObject::GLOBULAR_CLUSTER ||
o->type() == SkyObject::GALAXY_CLUSTER)
switch(o->type())
{
initobjects[Cluster_Model].append(o);
}
else if (o->type() == SkyObject::PLANETARY_NEBULA ||
o->type() == SkyObject::DARK_NEBULA ||
o->type() == SkyObject::GASEOUS_NEBULA)
{
initobjects[Nebula_Model].append(o);
}
else if (o->type() == SkyObject::STAR)
{
initobjects[Star_Model].append(o);
}
else if (o->type() == SkyObject::CONSTELLATION)
{
initobjects[Constellation_Model].append(o);
}
else if (o->type() == SkyObject::GALAXY)
{
initobjects[Galaxy_Model].append(o);
case SkyObject::OPEN_CLUSTER:
case SkyObject::GLOBULAR_CLUSTER:
case SkyObject::GALAXY_CLUSTER:
m_InitObjects[Cluster_Model].append(o);
break;
case SkyObject::PLANETARY_NEBULA:
case SkyObject::DARK_NEBULA:
case SkyObject::GASEOUS_NEBULA:
m_InitObjects[Nebula_Model].append(o);
break;
case SkyObject::STAR:
m_InitObjects[Star_Model].append(o);
break;
case SkyObject::CONSTELLATION:
m_InitObjects[Constellation_Model].append(o);
break;
case SkyObject::GALAXY:
m_InitObjects[Galaxy_Model].append(o);
break;
}
}
}
foreach (SkyObject *so, initobjects.value(Star_Model))
foreach (SkyObject *so, m_InitObjects.value(Star_Model))
{
//kDebug()<<so->longname()<<so->typeName();
if (obsconditions->isVisible(data->geo(), data->lst(), so))
if (m_ObsConditions->isVisible(data->geo(), data->lst(), so))
{
starsModel->addSkyObject(new SkyObjItem(so));
m_StarsModel->addSkyObject(new SkyObjItem(so));
}
}
foreach (SkyObject *so, initobjects.value(Galaxy_Model))
foreach (SkyObject *so, m_InitObjects.value(Galaxy_Model))
{
//kDebug()<<so->longname()<<so->typeName();
if (obsconditions->isVisible(data->geo(), data->lst(), so))
if (m_ObsConditions->isVisible(data->geo(), data->lst(), so))
{
galModel->addSkyObject(new SkyObjItem(so));
m_GalModel->addSkyObject(new SkyObjItem(so));
}
}
foreach (SkyObject *so, initobjects.value(Constellation_Model))
foreach (SkyObject *so, m_InitObjects.value(Constellation_Model))
{
if (obsconditions->isVisible(data->geo(), data->lst(), so))
if (m_ObsConditions->isVisible(data->geo(), data->lst(), so))
{
conModel->addSkyObject(new SkyObjItem(so));
m_ConModel->addSkyObject(new SkyObjItem(so));
}
}
foreach (SkyObject *so, initobjects.value(Cluster_Model))
foreach (SkyObject *so, m_InitObjects.value(Cluster_Model))
{
if (obsconditions->isVisible(data->geo(), data->lst(), so))
if (m_ObsConditions->isVisible(data->geo(), data->lst(), so))
{
clustModel->addSkyObject(new SkyObjItem(so));
m_ClustModel->addSkyObject(new SkyObjItem(so));
}
}
foreach (SkyObject *so, initobjects.value(Nebula_Model))
foreach (SkyObject *so, m_InitObjects.value(Nebula_Model))
{
if (obsconditions->isVisible(data->geo(), data->lst(), so))
if (m_ObsConditions->isVisible(data->geo(), data->lst(), so))
{
nebModel->addSkyObject(new SkyObjItem(so));
m_NebModel->addSkyObject(new SkyObjItem(so));
}
}
......@@ -144,22 +142,22 @@ void ModelManager::updateModels(ObsConditions *obs)
{
SkyObject *so = data->skyComposite()->findByName(name);
//kDebug()<<so->name()<<so->mag();
if (obsconditions->isVisible(data->geo(), data->lst(), so))
if (m_ObsConditions->isVisible(data->geo(), data->lst(), so))
{
if (so->name() == "Sun") continue;
planetsModel->addSkyObject(new SkyObjItem(so));
m_PlanetsModel->addSkyObject(new SkyObjItem(so));
}
}
}
void ModelManager::resetModels()
{
planetsModel->resetModel();
starsModel->resetModel();
conModel->resetModel();
galModel->resetModel();
clustModel->resetModel();
nebModel->resetModel();
m_PlanetsModel->resetModel();
m_StarsModel->resetModel();
m_ConModel->resetModel();
m_GalModel->resetModel();
m_ClustModel->resetModel();
m_NebModel->resetModel();
}
SkyObjListModel* ModelManager::returnModel(int type)
......@@ -167,17 +165,17 @@ SkyObjListModel* ModelManager::returnModel(int type)
switch(type)
{
case 0: //Planet type
return planetsModel;
return m_PlanetsModel;
case 1: //Star type
return starsModel;
return m_StarsModel;
case 2: //Constellation type
return conModel;
return m_ConModel;
case 3: //Galaxy Type
return galModel;
return m_GalModel;
case 4: //Cluster type
return clustModel;
return m_ClustModel;
case 5: //Nebula type
return nebModel;
return m_NebModel;
default:
return 0;
}
......
......@@ -62,13 +62,12 @@ public:
* \return Pointer to SkyObjListModel of given type.
* \param type Type of sky-object model to be returned.
*/
SkyObjListModel *returnModel (int type);
SkyObjListModel *returnModel(int type);
private:
ObsConditions *obsconditions;
SkyObjListModel *planetsModel, *starsModel, *galModel, *conModel, *clustModel, *nebModel;
QStringList baseCatList, planetaryList, deepSkyList;
QHash< ModelType, QList <SkyObject *> > initobjects;
ObsConditions *m_ObsConditions;
SkyObjListModel *m_PlanetsModel, *m_StarsModel, *m_GalModel, *m_ConModel, *m_ClustModel, *m_NebModel;
QHash< ModelType, QList <SkyObject *> > m_InitObjects;
};
#endif
......@@ -35,7 +35,7 @@ public:
* \enum Equipment
* Equipment available to the user.
*/
enum Equipment { Telescope = 0, Binoculars, Both, None };
enum Equipment { Telescope, Binoculars, Both, None };
/**
* \enum TelescopeType
......
......@@ -393,7 +393,7 @@ Rectangle {
objectName: "soListObj"
anchors.fill: parent
signal soListItemClicked( int type, string typeName, int curIndex )
signal soListItemClicked(int type, string typeName, int curIndex)
clip: true
ScrollBar {
......
......@@ -101,9 +101,14 @@ QString SkyObjItem::getDesc() const
while (fileReader.hasMoreLines())
{
QString line = fileReader.readLine();
if (line.split("::")[0] == m_Name)
if(line.length() != 0 && line[0] != '#')
{
return line.split("::")[1];
QString soname = line.split("::")[0];
QString desc = line.split("::")[1];
if (soname == m_Name)
{
return desc;
}
}
}
}
......
......@@ -19,7 +19,6 @@
#ifndef SKYOBJITEM_H
#define SKYOBJITEM_H
#include <QObject>
#include "skyobject.h"
/**
......
......@@ -25,13 +25,13 @@ SkyObjListModel::SkyObjListModel(SkyObjItem *soitem, QObject *parent): QAbstract
void SkyObjListModel::addSkyObject(SkyObjItem *soitem)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
soItemList.append(soitem);
m_SoItemList.append(soitem);
endInsertRows();
}
int SkyObjListModel::rowCount(const QModelIndex& parent) const
{
return soItemList.size();
return m_SoItemList.size();
}
QVariant SkyObjListModel::data(const QModelIndex& index, int role) const
......@@ -39,22 +39,22 @@ QVariant SkyObjListModel::data(const QModelIndex& index, int role) const
if (index.row() < 0 || index.row() > rowCount())
return QVariant();
SkyObjItem *soitem = soItemList[index.row()];
SkyObjItem *soitem = m_SoItemList[index.row()];
return soitem->data(role);
}
QList< SkyObjItem *> SkyObjListModel::getSkyObjItems()
{
return soItemList;
return m_SoItemList;
}
SkyObjItem* SkyObjListModel::getSkyObjItem(int index)
{
return soItemList[index];
return m_SoItemList[index];
}
void SkyObjListModel::resetModel()
{
soItemList.clear();
m_SoItemList.clear();
}
......@@ -72,7 +72,7 @@ public:
void resetModel();
private:
QList<SkyObjItem *> soItemList; ///List of sky-object items in model.
QList<SkyObjItem *> m_SoItemList; ///List of sky-object items in model.
};
#endif
......@@ -35,7 +35,7 @@ void WIUserSettings::makeConnections()
connect(binocularsCheck, SIGNAL( toggled(bool)), this, SLOT(slotBinocularsCheck(bool)));
}
void WIUserSettings::slotFinished(int)
void WIUserSettings::slotFinished(int status)
{
m_Equip = noEquipCheck->isEnabled()
? (ObsConditions::None)
......@@ -43,7 +43,7 @@ void WIUserSettings::slotFinished(int)
? (binocularsCheck->isChecked() ? ObsConditions::Both : ObsConditions::Telescope)
: (binocularsCheck->isChecked() ? ObsConditions::Binoculars : ObsConditions::None));
m_TelType = (equipmentType->currentText()=="Reflector") ? ObsConditions::Reflector : ObsConditions::Refractor;
m_TelType = (equipmentType->currentIndex() == 0) ? ObsConditions::Reflector : ObsConditions::Refractor;
KStars *kstars = KStars::Instance();
kstars->showWI(new ObsConditions(bortleClass->value(), aperture->value(), m_Equip, m_TelType));
......
......@@ -44,17 +44,17 @@ public slots:
/**
* \brief Finish wizard and display QML interface for "What's Interesting..."
*/
void slotFinished(int);
void slotFinished(int status);
/**
* \brief Telescope available - check/uncheck.
*/
void slotTelescopeCheck(bool);
void slotTelescopeCheck(bool on);
/**
* \brief Binoculars available - check/uncheck.
*/
void slotBinocularsCheck(bool);
void slotBinocularsCheck(bool on);
private:
......
......@@ -16,6 +16,8 @@
***************************************************************************/
#include "QDeclarativeView"
#include "QDeclarativeContext"
#include "QGraphicsObject"
#include "wiview.h"
#include "skymap.h"
......@@ -30,7 +32,7 @@ WIView::WIView(QWidget *parent, ObsConditions *obs) : QWidget(parent), m_Obs(obs
m_BaseView = new QDeclarativeView();
ctxt = m_BaseView->rootContext();
m_Ctxt = m_BaseView->rootContext();
m_BaseView->setSource(KStandardDirs::locate("appdata","tools/whatsinteresting/qml/wiview.qml"));
......@@ -72,7 +74,7 @@ WIView::~WIView()
void WIView::onCategorySelected(int type)
{
ctxt->setContextProperty("soListModel", m_ModManager->returnModel(type));
m_Ctxt->setContextProperty("soListModel", m_ModManager->returnModel(type));
}
void WIView::onSoListItemClicked(int type, QString typeName, int index)
......
......@@ -18,10 +18,9 @@
#ifndef WIVIEW_H
#define WIVIEW_H
#include "QtDeclarative/QDeclarativeView"
#include "QtDeclarative/QDeclarativeItem"
#include "QtDeclarative/QDeclarativeContext"
#include "QModelIndex"
class QDeclarativeView;
class QDeclarativeContext;
#include "skyobject.h"
#include "modelmanager.h"
#include "skyobjlistmodel.h"
......@@ -104,7 +103,7 @@ public slots:
private:
QObject *m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj,
*m_NextObj, *m_PrevObj, *m_SlewButtonObj, *m_DetailsButtonObj;
QDeclarativeContext *ctxt;
QDeclarativeContext *m_Ctxt;
QDeclarativeView *m_BaseView;
ObsConditions *m_Obs;
ModelManager *m_ModManager;
......
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