Commit ea78aabc authored by Samikshan Bairagya's avatar Samikshan Bairagya

Add a new QML GUI for What's Interesting... feature. Discard old boring interface.

parent 7e833635
add_subdirectory( data )
add_subdirectory( icons )
add_subdirectory( htmesh )
add_subdirectory( tools/whatsinteresting)
add_subdirectory( tools/whatsinteresting/qml)
Find_package(ZLIB REQUIRED)
......
import QtQuick 1.0
Rectangle {
id : base
width: 333
height: 575
color: "#21212b"
anchors.fill: parent
Text {
id: title
x: 14
y: 25
width: 195
height: 35
color: "#dee8f1"
text: qsTr("What's Interesting...")
font.family: "Cantarell"
verticalAlignment: Text.AlignVCenter
font.pixelSize: 19
}
Rectangle {
id: rectangle1
x: 14
y: 504
width: 200
height: 31
color: "#00000000"
Text {
id: text1
color: "#ffffff"
text: qsTr("What's Interesting Settings")
font.underline: true
verticalAlignment: Text.AlignVCenter
anchors.fill: parent
font.pixelSize: 12
MouseArea {
id: mouse_area1
x: 0
y: 0
anchors.fill: parent
}
}
}
Rectangle {
objectName: "container"
x: 14
y: 73
width: 305
height: 379
color: "#00000000"
border.color: "#ffffff"
ListView {
id: catListView
objectName: "catListObj"
anchors.fill: parent
visible: true
clip: true
signal catListItemClicked(string category)
delegate: Item {
id: baseListItem
objectName: modelData
x: 5
height: 40
//property variant item: modelData
Text {
text: modelData
color: "#ffffff"
anchors.verticalCenter: parent.verticalCenter
font.bold: true
MouseArea {
anchors.fill: parent
onClicked: {
catListView.currentIndex = index
switch (catListView.currentItem.objectName)
{
case "Planets" :
case "Satellites" :
case "Star" :
case "Galaxies" :
case "Constellations" :
case "Star Clusters" :
case "Nebulae" :
catListView.visible = false
soListView.visible = true
break;
}
catListView.catListItemClicked(catListView.currentItem.objectName)
}
}
}
}
model: catListModel
// ListModel {
// id : catListModel
// }
}
ListView {
id: soListView
objectName: "soListObj"
anchors.fill: parent
signal soListItemClicked( int type, string typeName, int curIndex )
clip: true
visible: false
delegate: Item {
id: soListItem
x: 5
height: 40
Text {
id: dispText
objectName: dispName
text: dispName
color: "#ffffff"
anchors.verticalCenter: parent.verticalCenter
font.bold: true
MouseArea {
anchors.fill: parent
onClicked: {
soListView.currentIndex = index
soListView.soListItemClicked(type, typeName, soListView.currentIndex)
}
}
}
}
model: soListModel
}
Rectangle {
id: detailsView
color: "#00000000"
radius: 5
objectName: "detailsViewObj"
anchors.fill: parent
visible: false
Text {
id: soname
objectName: "sonameObj"
x: 5
y: 5
width: 273
height: 44
color: "#ffffff"
text: qsTr("text")
font.bold: true
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
font.pixelSize: 16
}
Text {
id: posText
objectName: "posTextObj"
x: 5
y: 49
width: 291
height: 26
color: "#ffffff"
text: qsTr("text")
horizontalAlignment: Text.AlignRight
font.underline: true
font.italic: true
font.bold: true
font.pixelSize: 10
}
Rectangle {
x: 0
y: 84
width: 305
height: 175
color: "#00000000"
radius: 10
border.color: "#ffffff"
Flickable {
id: flickable1
clip: true
flickableDirection: Flickable.VerticalFlick
//anchors.fill: parent
width: parent.width
height: parent.height
anchors.top: parent.top
anchors.topMargin: 3
anchors.bottom: parent.bottom
anchors.bottomMargin: 4
contentWidth: parent.width
contentHeight: col.height
Column {
id: col
width: 300
Text {
id: descText
objectName: "descTextObj"
color: "#187988"
text: qsTr("text")
anchors.top: parent.top
anchors.topMargin: 3
anchors.left: parent.left
anchors.leftMargin: 4
clip: true
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
width: parent.width
//anchors.fill: parent
font.pixelSize: 12
}
}
}
}
Text {
id: nextObjText
objectName: "nextObj"
x: 195
y: 359
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()
}
}
Text {
id: magText
objectName: "magTextObj"
x: 102
y: 285
width: 80
height: 15
color: "#ffffff"
text: qsTr("text")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
}
}
}
Text {
id: soTypeText
objectName: "soTypeTextObj"
x: 189
y: 46
width: 130
height: 20
color: "#568656"
text: qsTr("text")
font.underline: true
font.italic: true
font.bold: true
verticalAlignment: Text.AlignBottom
horizontalAlignment: Text.AlignRight
font.pixelSize: 12
visible: false
}
}
#install_files
install( FILES Base.qml
DESTINATION ${DATA_INSTALL_DIR}/kstars/tools/whatsinteresting/ )
......@@ -146,9 +146,9 @@ void ModelManager::updateModels()
}
}
SkyObjListModel* ModelManager::returnModel(LIST_TYPE Type)
SkyObjListModel* ModelManager::returnModel(LIST_TYPE type)
{
switch(Type)
switch(type)
{
case Planets:
return planetsModel;
......@@ -167,15 +167,15 @@ SkyObjListModel* ModelManager::returnModel(LIST_TYPE Type)
}
}
SkyObjListModel* ModelManager::returnModel(QString Type)
SkyObjListModel* ModelManager::returnModel(QString type)
{
if (Type == "Planet")
if (type == "Planet")
return planetsModel;
else if (Type == "Star")
else if (type == "Star")
return starsModel;
else if (Type == "Galaxy")
else if (type == "Galaxy")
return galModel;
else if (Type == "Constellation")
else if (type == "Constellation")
return conModel;
// else if (Type == "Star_Clusters")
// return starClustModel;
......@@ -191,8 +191,6 @@ QStringList ModelManager::returnCatListModel(ModelManager::LIST_TYPE Type)
{
case BaseList:
return baseCatList;
case PlanetaryObjects:
return planetaryList;
default:
return deepSkyList;
}
......
......@@ -23,13 +23,12 @@
class ModelManager
{
public:
enum LIST_TYPE {BaseList, PlanetaryObjects, DeepSkyObjects, Planets, Satellites,
Stars, Galaxies, Constellations, Clusters, Nebulae};
enum LIST_TYPE { BaseList, DeepSkyObjects, Planets, Stars, Galaxies, Constellations, Clusters, Nebulae };
ModelManager(ObsConditions *obs);
~ModelManager();
void updateModels();
SkyObjListModel* returnModel ( LIST_TYPE Type );
SkyObjListModel* returnModel ( LIST_TYPE type );
SkyObjListModel* returnModel ( QString type );
QStringList returnCatListModel ( LIST_TYPE Type );
......
#install_files
install( FILES wiview.qml
planets.jpg
stars.jpg
constellation.jpg
dso.jpg
galaxy.jpg
cluster.jpg
nebula.jpg
stripes.png
DESTINATION ${DATA_INSTALL_DIR}/kstars/tools/whatsinteresting/qml )
This diff is collapsed.
......@@ -28,15 +28,16 @@ WIView::WIView ( QObject *parent, ObsConditions *obs) : QObject(parent)
QDeclarativeView *baseView = new QDeclarativeView();
ctxt = baseView->rootContext();
ctxt->setContextProperty("catListModel", QVariant::fromValue(m->returnCatListModel( ModelManager::BaseList )));
baseView->setSource(KStandardDirs::locate("appdata","tools/whatsinteresting/Base.qml") );
baseView->setSource(KStandardDirs::locate("appdata","tools/whatsinteresting/qml/wiview.qml") );
baseObj = dynamic_cast<QObject *> (baseView->rootObject());
soTypeTextObj = baseObj->findChild<QObject *>("soTypeTextObj") ;
soTypeTextObj = baseObj->findChild<QObject *>("soTypeTextObj");
catListObj = baseObj->findChild<QObject *>("catListObj");
connect(catListObj, SIGNAL(catListItemClicked(QString)), this, SLOT(onCatListItemClicked(QString)));
containerObj = baseObj->findChild<QObject *>("containerObj");
viewsRowObj = baseObj->findChild<QObject *>("viewsRowObj");
connect(viewsRowObj, SIGNAL(categorySelected(int)), this, SLOT(onCategorySelected(int)));
soListObj = baseObj->findChild<QObject *>("soListObj");
connect(soListObj, SIGNAL(soListItemClicked(int, QString, int)), this, SLOT(onSoListItemClicked(int, QString, int)));
......@@ -55,61 +56,88 @@ WIView::~WIView()
delete curSoItem;
}
void WIView::onCatListItemClicked(QString category)
//void WIView::onCatListItemClicked(QString category)
//{
// if (category == "Deep-sky Objects")
// {
// ctxt->setContextProperty("catListModel", QVariant::fromValue(m->returnCatListModel( ModelManager::DeepSkyObjects )));
// soTypeTextObj->setProperty("text", category);
// soTypeTextObj->setProperty("visible", true);
// }
// else if (category == "Planets")
// {
// ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Planets ));
// catListObj->setProperty("visible", false);
// soListObj->setProperty("visible", true);
// soTypeTextObj->setProperty("text", category);
// soTypeTextObj->setProperty("visible", true);
// }
// else if (category == "Stars")
// {
// ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Stars ));
// catListObj->setProperty("visible", false);
// soListObj->setProperty("visible", true);
// soTypeTextObj->setProperty("text", category);
// soTypeTextObj->setProperty("visible", true);
// }
// else if (category == "Galaxies")
// {
// ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Galaxies ));
// catListObj->setProperty("visible", false);
// soListObj->setProperty("visible", true);
// soTypeTextObj->setProperty("text", category);
// soTypeTextObj->setProperty("visible", true);
// }
// else if (category == "Constellations")
// {
// ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Constellations ));
// catListObj->setProperty("visible", false);
// soListObj->setProperty("visible", true);
// soTypeTextObj->setProperty("text", category);
// soTypeTextObj->setProperty("visible", true);
// }
// else if (category == "Clusters")
// {
// ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Clusters ));
// catListObj->setProperty("visible", false);
// soListObj->setProperty("visible", true);
// soTypeTextObj->setProperty("text", category);
// soTypeTextObj->setProperty("visible", true);
// }
// else if (category == "Nebulae")
// {
// ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Nebulae ));
// catListObj->setProperty("visible", false);
// soListObj->setProperty("visible", true);
// soTypeTextObj->setProperty("text", category);
// soTypeTextObj->setProperty("visible", true);
// }
//}
void WIView::onCategorySelected(int type)
{
if (category == "Deep-sky Objects")
{
ctxt->setContextProperty("catListModel", QVariant::fromValue(m->returnCatListModel( ModelManager::DeepSkyObjects )));
soTypeTextObj->setProperty("text", category);
soTypeTextObj->setProperty("visible", true);
}
else if (category == "Planets")
switch(type)
{
case 0:
kDebug()<<"Planets Selected";
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Planets ));
catListObj->setProperty("visible", false);
soListObj->setProperty("visible", true);
soTypeTextObj->setProperty("text", category);
soTypeTextObj->setProperty("visible", true);
}
else if (category == "Stars")
{
kDebug()<<"Model created successfully";
break;
case 1:
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Stars ));
catListObj->setProperty("visible", false);
soListObj->setProperty("visible", true);
soTypeTextObj->setProperty("text", category);
soTypeTextObj->setProperty("visible", true);
}
else if (category == "Galaxies")
{
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Galaxies ));
catListObj->setProperty("visible", false);
soListObj->setProperty("visible", true);
soTypeTextObj->setProperty("text", category);
soTypeTextObj->setProperty("visible", true);
}
else if (category == "Constellations")
{
break;
case 2:
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Constellations ));
catListObj->setProperty("visible", false);
soListObj->setProperty("visible", true);
soTypeTextObj->setProperty("text", category);
soTypeTextObj->setProperty("visible", true);
}
else if (category == "Clusters")
{
break;
case 3:
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Galaxies ));
break;
case 4:
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Clusters ));
catListObj->setProperty("visible", false);
soListObj->setProperty("visible", true);
soTypeTextObj->setProperty("text", category);
soTypeTextObj->setProperty("visible", true);
}
else if (category == "Nebulae")
{
break;
case 5:
ctxt->setContextProperty("soListModel", m->returnModel( ModelManager::Nebulae ));
catListObj->setProperty("visible", false);
soListObj->setProperty("visible", true);
soTypeTextObj->setProperty("text", category);
soTypeTextObj->setProperty("visible", true);
break;
}
}
......@@ -155,10 +183,10 @@ void WIView::onSoListItemClicked(int type, QString typeName, int index)
// }
kDebug()<<soitem->getName()<<soitem->getType();
soTypeTextObj->setProperty("text", typeName);
soTypeTextObj->setProperty("visible", true);
// soTypeTextObj->setProperty("text", typeName);
// soTypeTextObj->setProperty("visible", true);
soListObj->setProperty("visible", false);
// soListObj->setProperty("visible", false);
loadDetailsView(soitem , index);
}
......@@ -173,8 +201,6 @@ void WIView::loadDetailsView(SkyObjItem* soitem, int index)
descTextObj->setProperty("text", soitem->getDesc());
magTextObj->setProperty("text", soitem->getMagnitude());
detailsViewObj->setProperty("visible", true);
//Slew map to selected sky object
SkyObject* so = soitem->getSkyObject();
KStars* data = KStars::Instance();
......
......@@ -32,21 +32,12 @@ public:
void loadDetailsView(SkyObjItem* soitem, int index);
public slots:
// void loadModel ( int TYPE );
// void skyObjectItemClicked(QModelIndex index);
void onCatListItemClicked(QString);
void onCategorySelected(int);
void onSoListItemClicked(int type, QString typeName, int index);
void onNextObjTextClicked();
private:
QObject *baseObj, *catListObj, *soListObj, *detailsViewObj, *nextObj, *soTypeTextObj;
QObject *baseObj, *containerObj, *viewsRowObj, *soListObj, *detailsViewObj, *nextObj, *soTypeTextObj;
QDeclarativeContext *ctxt;
QDeclarativeView *baseListView;
QDeclarativeView *planetaryListView;
QDeclarativeView *deepSkyListView;
QDeclarativeView *skyObjListView;
QDeclarativeView *planetDetailsView;
QDeclarativeView *satelliteDetailsView;
QDeclarativeView *deepSkyDetailsView;
ModelManager *m;
SkyObjItem *curSoItem;
int curIndex;
......
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