Commit eb65f8ad authored by Samikshan Bairagya's avatar Samikshan Bairagya

Added "Show previous sky-object" option as well. Also changed the text...

Added "Show previous sky-object" option as well. Also changed the text indicating position of sky-object to denote approximation in the position.
parent 866521c4
......@@ -3,4 +3,6 @@
install( FILES wiview.qml
leftArrow.png
settingsIcon.png
next.png
previous.png
DESTINATION ${DATA_INSTALL_DIR}/kstars/tools/whatsinteresting/qml )
......@@ -514,34 +514,6 @@ Rectangle {
}
}
Text {
id: nextObjText
objectName: "nextObj"
x: parent.width - 110
y: 359
width: 101
height: 15
color: "white"
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: nextObjMouseArea
anchors.fill: parent
hoverEnabled: true
onEntered: nextObjText.color = "yellow"
onExited: nextObjText.color = "white"
onClicked: nextObjText.nextObjTextClicked()
}
}
Text {
id: magText
objectName: "magTextObj"
......@@ -557,6 +529,137 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 12
}
Rectangle {
id: nextObjRect
objectName: "nextObj"
x: 183
y: 347
width: 147
height: 28
color: "#00000000"
radius: 5
signal nextObjClicked()
Rectangle {
id: nextObjForeground
radius: 5
anchors.fill: nextObjText
opacity: 0
}
MouseArea {
id: nextObjMouseArea
x: 13
y: 62
anchors.fill: nextObjText
hoverEnabled: true
onEntered: {
nextObjForeground.opacity = 0.1
nextObjText.color = "yellow"
}
onExited: {
nextObjForeground.opacity = 0.0
nextObjText.color = "white"
}
onClicked: nextObjRect.nextObjClicked()
}
Text {
id: nextObjText
objectName: "nextTextObj"
y: 17
height: 22
color: "white"
text: qsTr("Next")
anchors.right: nextObjIcon.left
anchors.rightMargin: 5
anchors.verticalCenter: parent.verticalCenter
visible: true
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight
font.bold: true
font.pixelSize: 11
x: 7
}
Image {
id: nextObjIcon
x: 123
y: 13
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: 24
sourceSize.width: 24
source: "next.png"
}
}
Rectangle {
id: prevObjRect
objectName: "prevObj"
x: 10
y: 347
width: 147
height: 28
color: "#00000000"
radius: 5
signal prevObjClicked()
Rectangle {
id: prevObjForeground
radius: 5
anchors.fill: prevObjText
opacity: 0
}
MouseArea {
id: prevObjMouseArea
x: 13
y: 62
hoverEnabled: true
anchors.fill: prevObjText
onEntered: {
prevObjForeground.opacity = 0.1
prevObjText.color = "yellow"
}
onExited: {
prevObjForeground.opacity = 0.0
prevObjText.color = "white"
}
onClicked: prevObjRect.prevObjClicked()
}
Text {
id: prevObjText
objectName: "prevTextObj"
y: 7
height: 22
color: "#ffffff"
text: qsTr("Previous")
anchors.left: prevObjIcon.right
anchors.leftMargin: 5
anchors.verticalCenterOffset: 0
font.pixelSize: 11
visible: true
anchors.verticalCenter: parent.verticalCenter
font.bold: true
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
Image {
id: prevObjIcon
x: 0
y: 2
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: 24
sourceSize.width: 24
source: "previous.png"
}
}
} //end of detailsView
} //end of detailsViewContainer
......
......@@ -91,7 +91,7 @@ void SkyObjItem::setPosition(SkyObject* so)
double rounded_altitude = (int)(sp.alt().Degrees()/5.0)*5.0;
int rounded_azimuth = (int)(sp.az().Degrees()/22.5);
m_Position = QString("Now visible: ") + (QString::number(rounded_altitude)) + (" degrees above the ") + (cardinals[rounded_azimuth]) + (" horizon ");
m_Position = QString("Now visible: About ") + (QString::number(rounded_altitude)) + (" degrees above the ") + (cardinals[rounded_azimuth]) + (" horizon ");
}
QString SkyObjItem::getDesc() const
......
......@@ -26,10 +26,17 @@ WIView::WIView(QObject *parent, ObsConditions *obs) : QObject(parent)
m = new ModelManager(obs);
// KStars *data = KStars::Instance();
// SkyMap *skyMap = data->map();
// QGraphicsScene *mapScene = new QGraphicsScene(skyMap);
QDeclarativeView *baseView = new QDeclarativeView();
baseView->setAttribute(Qt::WA_TranslucentBackground);
baseView->setStyleSheet("background: transparent;");
// baseView->setWindowFlags(Qt::FramelessWindowHint);
ctxt = baseView->rootContext();
......@@ -46,12 +53,23 @@ WIView::WIView(QObject *parent, ObsConditions *obs) : QObject(parent)
connect(m_SoListObj, SIGNAL(soListItemClicked(int, QString, int)), this, SLOT(onSoListItemClicked(int, QString, int)));
m_DetailsViewObj = m_BaseObj->findChild<QObject *>("detailsViewObj");
m_NextObj = m_BaseObj->findChild<QObject *>("nextObj");
connect(m_NextObj, SIGNAL(nextObjTextClicked()), this, SLOT(onNextObjTextClicked()));
connect(m_NextObj, SIGNAL(nextObjClicked()), this, SLOT(onNextObjClicked()));
m_PrevObj = m_BaseObj->findChild<QObject *>("prevObj");
connect(m_PrevObj, SIGNAL(prevObjClicked()), this, SLOT(onPrevObjClicked()));
m_OptMag = obs->getOptimumMAG();
baseView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
// baseView->setParent(skyMap);
// mapScene->addItem(qobject_cast<QGraphicsObject *>(baseView->rootObject()));
// mapScene->setItemIndexMethod(QGraphicsScene::NoIndex);
// skyMap->setScene(mapScene);
// skyMap->setOptimizationFlags(QGraphicsView::DontSavePainterState);
// skyMap->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
baseView->show();
}
......@@ -90,11 +108,26 @@ void WIView::onSoListItemClicked(int type, QString typeName, int index)
// soTypeTextObj->setProperty("visible", true);
// soListObj->setProperty("visible", false);
loadDetailsView(soitem, index);
}
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);
//QString nextObjText = QString("Next: ") + nextItem->getName();
QObject *nextTextObj = m_NextObj->findChild<QObject *>("nextTextObj");
nextTextObj->setProperty("text", nextItem->getName());
//QString prevObjText = QString("Previous: ") + prevItem->getName();
QObject *prevTextObj = m_PrevObj->findChild<QObject *>("prevTextObj");
prevTextObj->setProperty("text", prevItem->getName());
QObject *sonameObj = m_DetailsViewObj->findChild<QObject *>("sonameObj");
QObject *posTextObj = m_DetailsViewObj->findChild<QObject *>("posTextObj");
QObject *descTextObj = m_DetailsViewObj->findChild<QObject *>("descTextObj");
......@@ -112,14 +145,18 @@ void WIView::loadDetailsView(SkyObjItem *soitem, int index)
data->map()->setFocusObject(so);
data->map()->setDestination(*data->map()->focusPoint());
}
m_CurSoItem = soitem;
m_CurIndex = index;
}
void WIView::onNextObjTextClicked()
void WIView::onNextObjClicked()
{
int modelSize = m->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *nextItem = m->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);
loadDetailsView(prevItem, (m_CurIndex-1+modelSize)%modelSize);
}
......@@ -19,6 +19,7 @@
#define WIVIEW_H
#include "QtDeclarative/QDeclarativeView"
#include "QtDeclarative/QDeclarativeItem"
#include "QtDeclarative/QDeclarativeContext"
#include "QModelIndex"
#include "skyobject.h"
......@@ -68,8 +69,8 @@ public slots:
/**
* \brief public slot - Act upon signal emitted when an item is selected from list of sky-objects.
* Display details-view for the skyobject selected.
* \param type Category selected
* \param typename Name of category selected
* \param type Category selected.
* \param typename Name of category selected.
* \param index Index of item in the list of skyobjects.
*/
void onSoListItemClicked(int type, QString typeName, int index);
......@@ -77,10 +78,15 @@ public slots:
/**
* \brief public slot - Show details-view for next sky-object from list of current sky-objects's category.
*/
void onNextObjTextClicked();
void onNextObjClicked();
/**
* \brief public slot - Show details-view for previous sky-object from list of current sky-objects's category.
*/
void onPrevObjClicked();
private:
QObject *m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj, *m_NextObj;
QObject *m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj, *m_NextObj, *m_PrevObj;
QDeclarativeContext *ctxt;
ModelManager *m;
SkyObjItem *m_CurSoItem; ///Current sky-object item.
......
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