Commit 91e3f724 authored by Samikshan Bairagya's avatar Samikshan Bairagya

Added documentation for SkyObjListModel class.

parent fe45f24d
......@@ -22,20 +22,57 @@
#include "skyobject.h"
#include "skyobjitem.h"
/**
* \class SkyObjListModel
* Represents a model for the list of interesting sky-objects to be displayed in the QML interface.
* \author Samikshan Bairagya
*/
class SkyObjListModel : public QAbstractListModel
{
Q_OBJECT
public:
/**
* \brief Constructor
*/
explicit SkyObjListModel(SkyObjItem *soitem = 0, QObject *parent = 0);
/**
* \brief Add a sky-object to the model.
* \param sobj Pointer to sky-object to be added.
*/
void addSkyObject(SkyObjItem *sobj);
/**
* \brief Overriden method from QAbstractItemModel.
* \return The number of items in the sky-object list model.
*/
int rowCount(const QModelIndex& parent = QModelIndex()) const;
/**
* \brief Overriden method from QAbstractItemModel.
* \return Data stored under the given role for the sky-object item referred to by the index.
*/
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
/**
* \brief Get the list of sky-object items in the model.
* \return A QList of pointers to SkyObjItems which are there in the model.
*/
QList<SkyObjItem *> getSkyObjItems();
/**
* \brief Get sky-object item referred to by index.
* \return Pointer to SkyObjItem referred to by index.
*/
SkyObjItem *getSkyObjItem(int index);
/**
* \brief Erase all data in model.
*/
void resetModel();
private:
QList<SkyObjItem *> soItemList;
QList<SkyObjItem *> soItemList; ///List of sky-object items in model.
};
#endif
......@@ -26,7 +26,7 @@
WIView::WIView(QWidget *parent, ObsConditions *obs) : QWidget(parent), m_Obs(obs)
{
m = new ModelManager(obs);
m_ModManager = new ModelManager(obs);
m_BaseView = new QDeclarativeView();
......@@ -66,18 +66,18 @@ WIView::WIView(QWidget *parent, ObsConditions *obs) : QWidget(parent), m_Obs(obs
WIView::~WIView()
{
delete m;
delete m_ModManager;
delete m_CurSoItem;
}
void WIView::onCategorySelected(int type)
{
ctxt->setContextProperty("soListModel", m->returnModel(type));
ctxt->setContextProperty("soListModel", m_ModManager->returnModel(type));
}
void WIView::onSoListItemClicked(int type, QString typeName, int index)
{
SkyObjItem *soitem = m->returnModel(type)->getSkyObjItem(index);
SkyObjItem *soitem = m_ModManager->returnModel(type)->getSkyObjItem(index);
// soTypeTextObj->setProperty("text", typeName);
// soTypeTextObj->setProperty("visible", true);
......@@ -93,9 +93,9 @@ void WIView::loadDetailsView(SkyObjItem *soitem, int index)
m_CurSoItem = soitem;
m_CurIndex = index;
int modelSize = m->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *nextItem = m->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex+1)%modelSize);
SkyObjItem *prevItem = m->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex-1+modelSize)%modelSize);
int modelSize = m_ModManager->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *nextItem = m_ModManager->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex+1)%modelSize);
SkyObjItem *prevItem = m_ModManager->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex-1+modelSize)%modelSize);
QObject *nextTextObj = m_NextObj->findChild<QObject *>("nextTextObj");
nextTextObj->setProperty("text", nextItem->getName());
......@@ -129,15 +129,15 @@ void WIView::loadDetailsView(SkyObjItem *soitem, int index)
void WIView::onNextObjClicked()
{
int modelSize = m->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *nextItem = m->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex+1)%modelSize);
int modelSize = m_ModManager->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *nextItem = m_ModManager->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex+1)%modelSize);
loadDetailsView(nextItem, (m_CurIndex+1)%modelSize);
}
void WIView::onPrevObjClicked()
{
int modelSize = m->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *prevItem = m->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex-1+modelSize)%modelSize);
int modelSize = m_ModManager->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *prevItem = m_ModManager->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex-1+modelSize)%modelSize);
loadDetailsView(prevItem, (m_CurIndex-1+modelSize)%modelSize);
}
......
......@@ -57,7 +57,7 @@ public:
*/
void loadDetailsView(SkyObjItem* soitem, int index);
inline void updateModels(ObsConditions *obs) { m->updateModels(obs); }
inline void updateModels(ObsConditions *obs) { m_ModManager->updateModels(obs); }
inline QDeclarativeView *getWIBaseView() const { return m_BaseView; }
......@@ -107,7 +107,7 @@ private:
QDeclarativeContext *ctxt;
QDeclarativeView *m_BaseView;
ObsConditions *m_Obs;
ModelManager *m;
ModelManager *m_ModManager;
SkyObjItem *m_CurSoItem; ///Current sky-object item.
int m_CurIndex; ///Index of current sky-object item in details-view.
};
......
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