Commit 631e95e5 authored by Samikshan Bairagya's avatar Samikshan Bairagya

Add option in details-view to view next sky-object.

parent 1b1cd29d
......@@ -228,6 +228,31 @@ Rectangle {
}
}
}
Text {
id: nextObjText
objectName: "nextObj"
x: 195
y: 276
width: 101
height: 15
color: "#ffffff"
text: qsTr("Next sky-object")
visible: true
verticalAlignment: Text.AlignBottom
horizontalAlignment: Text.AlignRight
font.bold: true
font.underline: true
font.pixelSize: 11
signal nextObjTextClicked()
MouseArea {
id: mouse_area2
anchors.fill: parent
onClicked: nextObjText.nextObjTextClicked()
}
}
}
}
}
......@@ -40,6 +40,8 @@ WIView::WIView ( QObject *parent) : QObject(parent)
connect(soListObj, SIGNAL(soListItemClicked(QString, int)),
this, SLOT(onSoListItemClicked(QString, int)));
detailsViewObj = baseObj->findChild<QObject *>("container")->findChild<QObject *>("detailsViewObj");
nextObj = baseObj->findChild<QObject *>("nextObj");
connect(nextObj, SIGNAL(nextObjTextClicked()), this, SLOT(onNextObjTextClicked()));
// planetaryListView->setSource(QUrl::fromLocalFile("WIPlanetaryListView.qml"));
......@@ -133,16 +135,27 @@ void WIView::onSoListItemClicked(QString type, int index)
}
soListObj->setProperty("visible", false);
loadDetailsView(soitem);
loadDetailsView(soitem , index);
}
void WIView::loadDetailsView(SkyObjItem* soitem)
void WIView::loadDetailsView(SkyObjItem* soitem, int index)
{
QObject* sonameObj = detailsViewObj->findChild<QObject *>("sonameObj");
QObject* posTextObj = detailsViewObj->findChild<QObject *>("posTextObj");
QObject* descTextObj = detailsViewObj->findChild<QObject *>("descTextObj");
sonameObj->setProperty("text", soitem->getName());
posTextObj->setProperty("text", soitem->getPosition());
detailsViewObj->setProperty("visible", true);
descTextObj->setProperty("text", soitem->getDesc());
detailsViewObj->setProperty("visible", true);
curSoItem = soitem;
curIndex = index;
}
void WIView::onNextObjTextClicked()
{
int modelSize = m->returnModel(curSoItem->getType())->rowCount();
SkyObjItem *nextItem = m->returnModel(curSoItem->getType())->getSkyObjItem((curIndex+1)%modelSize);
loadDetailsView(nextItem, (curIndex+1)%modelSize);
}
......@@ -16,6 +16,7 @@
***************************************************************************/
#include "QtDeclarative/QDeclarativeView"
#include "QtDeclarative/QDeclarativeContext"
#include "QModelIndex"
#include "skyobject.h"
#include "modelmanager.h"
......@@ -31,24 +32,25 @@ public:
WIView(QObject *parent = 0);
~WIView();
void manageViews(int TYPE); //display view
void loadDetailsView( SkyObjItem* soitem);
void loadDetailsView( SkyObjItem* soitem, int index);
public slots:
// void loadModel ( int TYPE );
// void skyObjectItemClicked(QModelIndex index);
void onCatListItemClicked(QString);
void onSoListItemClicked(QString, int index);
void onNextObjTextClicked();
private:
QObject *baseObj, *catListObj, *soListObj, *detailsViewObj;
QObject *baseObj, *catListObj, *soListObj, *detailsViewObj, *nextObj;
QDeclarativeContext *ctxt;
QDeclarativeView *baseListView;
QDeclarativeView *planetaryListView;
QDeclarativeView *deepSkyListView;
QDeclarativeView *skyObjListView;
QDeclarativeView *planetDetailsView;
QDeclarativeView *satelliteDetailsView;
QDeclarativeView *deepSkyDetailsView;
ModelManager *m;
SkyObjItem *curSoItem;
int curIndex;
};
\ No newline at end of file
......@@ -165,6 +165,24 @@ SkyObjListModel* ModelManager::returnModel(ModelManager::LIST_TYPE Type)
return (new SkyObjListModel());
}
SkyObjListModel* ModelManager::returnModel(QString Type)
{
if (Type == "Planet")
return planetsModel;
else if (Type == "Star")
return starsModel;
else if (Type == "Galaxy")
return galModel;
else if (Type == "Constellation")
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)
......
......@@ -32,6 +32,7 @@ public:
//QStandardItemModel* returnModel ( int TYPE );
SkyObjListModel* returnModel ( LIST_TYPE Type );
SkyObjListModel* returnModel ( QString type );
QStringList returnCatListModel ( LIST_TYPE Type );
bool isVisible(GeoLocation* geo, dms* lst, SkyObject* so);
......
......@@ -32,7 +32,7 @@ public:
int rowCount( const QModelIndex& parent = QModelIndex()) const;
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole) const;
QList<SkyObjItem *> getSkyObjItems();
SkyObjItem* getSkyObjItem(int index);
SkyObjItem* getSkyObjItem ( int index );
private:
QList<SkyObjItem *> soItemList;
......
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