Commit f35c6779 authored by Samikshan Bairagya's avatar Samikshan Bairagya

Details-view to open when a sky-object item is clicked from the list of sky objects.

This works for Stars, Constellations and Planets for now.
parent 7e056c47
......@@ -56,7 +56,7 @@ Rectangle {
}
Rectangle {
objectName: "listContainer"
objectName: "container"
x: 14
y: 86
width: 305
......@@ -117,7 +117,7 @@ Rectangle {
objectName: "soListObj"
anchors.fill: parent
signal soListItemClicked( string name, string type)
signal soListItemClicked( string type, int curIndex )
clip: true
visible: false
......@@ -137,7 +137,7 @@ Rectangle {
anchors.fill: parent
onClicked: {
soListView.currentIndex = index
soListView.soListItemClicked( dispText.objectName, soListItem.objectName)
soListView.soListItemClicked( soListItem.objectName , soListView.currentIndex)
}
}
}
......@@ -145,5 +145,26 @@ Rectangle {
model: soListModel
}
Rectangle {
id: detailsView
color: "#00000000"
radius: 5
objectName: "detailsViewObj"
anchors.fill: parent
visible: false
Text {
id: soname
objectName: "sonameObj"
x: 17
y: 24
width: 268
height: 230
text: qsTr("text")
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pixelSize: 12
}
}
}
}
......@@ -33,11 +33,12 @@ WIView::WIView ( QObject *parent) : QObject(parent)
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");
catListObj = baseObj->findChild<QObject *>("container")->findChild<QObject *>("catListObj");
connect(catListObj, SIGNAL(catListItemClicked(QString)), this, SLOT(onCatListItemClicked(QString)));
soListObj = baseObj->findChild<QObject *>("listContainer")->findChild<QObject *>("soListObj");
connect(soListObj, SIGNAL(soListItemClicked(QString, QString)),
this, SLOT(onSoListItemClicked(QString, QString)));
soListObj = baseObj->findChild<QObject *>("container")->findChild<QObject *>("soListObj");
connect(soListObj, SIGNAL(soListItemClicked(QString, int)),
this, SLOT(onSoListItemClicked(QString, int)));
detailsViewObj = baseObj->findChild<QObject *>("container")->findChild<QObject *>("detailsViewObj");
// planetaryListView->setSource(QUrl::fromLocalFile("WIPlanetaryListView.qml"));
......@@ -110,8 +111,23 @@ void WIView::onCatListItemClicked(QString category)
}
}
void WIView::onSoListItemClicked(QString name, QString type)
void WIView::onSoListItemClicked(QString type, int index)
{
kDebug()<<"Working"<<name<<type;
SkyObjItem *soitem;
if (type == "Star")
soitem = m->returnModel(ModelManager::Stars)->getSkyObjItem(index);
else if (type == "Constellation")
soitem = m->returnModel(ModelManager::Constellations)->getSkyObjItem(index);
else if (type == "Planet")
soitem = m->returnModel(ModelManager::Planets)->getSkyObjItem(index);
kDebug()<<soitem->getName()<<soitem->getType();
soListObj->setProperty("visible", false);
loadDetailsView(soitem);
}
void WIView::loadDetailsView(SkyObjItem* soitem)
{
QObject* sonameObj = detailsViewObj->findChild<QObject *>("sonameObj");
sonameObj->setProperty("text", soitem->getName());
detailsViewObj->setProperty("visible", true);
}
......@@ -31,15 +31,15 @@ public:
WIView(QObject *parent = 0);
~WIView();
void manageViews(int TYPE); //display view
void loadDetailsView( int detailsViewType, SkyObject *so);
void loadDetailsView( SkyObjItem* soitem);
public slots:
// void loadModel ( int TYPE );
// void skyObjectItemClicked(QModelIndex index);
void onCatListItemClicked(QString);
void onSoListItemClicked(QString name, QString type);
void onSoListItemClicked(QString, int index);
private:
QObject *baseObj, *catListObj, *soListObj;
QObject *baseObj, *catListObj, *soListObj, *detailsViewObj;
QDeclarativeContext *ctxt;
QDeclarativeView *baseListView;
QDeclarativeView *planetaryListView;
......
......@@ -54,3 +54,8 @@ QList< SkyObjItem* > SkyObjListModel::getSkyObjItems()
return soItemList;
}
SkyObjItem* SkyObjListModel::getSkyObjItem(int index)
{
return soItemList[index];
}
......@@ -32,6 +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);
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